Registry Mirror
Skip to content

Conversation

@backnotprop

@backnotprop backnotprop commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Step 2 of the Inbox MCP size work (step 1 was #1999). Owner-approved scope; the window size and re-read questions were skipped, so this builds the recommendations: newest 6 in full, the same window on every read, after as an option. Agent search is approved in .product/approved/inbox-agent-search/approval.md.

What changes

read_thread reads a window (packages/server/inbox-mcp-read.ts):

  • Header: subject, name, project, who wrote how many messages, and every question still waiting on the person (open or picked) with message_id/key, Q<n>, state, prompt and choices.
  • The newest limit messages in full (default 6).
  • The person's earlier messages in full, newest first, while they total 12 KB or less. Each is shown without its "Answers to your questions" section, because those answers are on the questions. 12 KB holds every reply in the longest thread measured (17 replies, about 12 KB, in 46 messages). It still bounds a thread of hundreds of rounds to about 3k tokens of the person's words.
  • Every other earlier message as one line: id, author, time, first words, size, and each question's state and answer.
  • A body over 16 KB is cut, with a marker that names the expand call.
  • New arguments: expand: [ids] and message_id show messages exactly as sent. before / after take a message id or a cursor. format: "full" returns the old records.
  • No question state is lost: a question that before/after leaves out is listed in thread.questions.
  • Messages keep the record field names (id, author.kind, body, questions[].key/state/answer, attachments[].path, ack, guide.title). The bookkeeping is gone: sha256s, mtimes, revisions, idempotency keys, repeated ids, pickers, inline-image records, delivery.

Text-complete results. read_thread (both modes), search and wait_for_reply set _meta["ai.plannotator/text-complete"]. Their text is a complete transcript. inboxToolResultText in the contract (the mod's copy too; Pi vendors it) then hands the model the text alone. send_message, submit_guide, resolve_message and format: "full" are not marked. An older connection ignores the mark and appends the trimmed JSON. The phone proofs' fields (wait_for_reply status / reply.body, send_message questions[].key) are unchanged.

search (packages/server/inbox-mcp-search.ts): a read-only search over the window's ⌘K index, in the caller's project unless all_projects.

  • Results are compact rows: thread, message, author, time, snippet.
  • It writes nothing: no store line, no recent search, no read mark.
  • The stdio shim fills its project_path.
  • It is added to INBOX_MCP_TOOLS, INBOX_TOOL_ACTIONS, the help guide and the bundled mod tool list. The agent tool's description is 1,736 characters (Claude Code's cap is 2,048).
  • The AGENTS.md "Search" rule now names the approval that supersedes it.

Tool cost. The plannotator_inbox entry measured on the real Pi is 7,328 bytes (1,732 o200k tokens). Main's 6,390 was an estimate. INBOX_TOOL_COST now says "about 7 KB, roughly 2,000 tokens". OpenCode 2's cost test runs in CI.

Sizes (what the hosts hand the model, seeded threads, o200k_base)

Measured after the review fixes (prompts on one-line questions, answers whole as JSON strings, the person's newest message whole).

Call main bytes main tokens this PR bytes this PR tokens older host on this PR (bytes)
read_thread, 120 messages – – 40,401 13,846 100,305
read_thread, 120 messages, after with nothing new – – 763 243 1,469
read_thread, 60 messages 99,971 34,689 21,187 7,213 52,287
read_thread, 60 messages, after with nothing new – – 759 237 1,461
read_thread, 46 messages 76,535 26,319 16,692 5,636 41,054
read_thread, 3 messages 6,065 2,032 2,589 854 6,001
read_thread list (17 threads) 5,719 1,959 2,759 1,222 8,459
wait_for_reply (with a reply) 1,446 523 653 255 1,710

The MCP server instructions are 1,981 characters (cap 2,048). The agent tool's description is 1,736.

Review fixes (second and third commits)

  • A windowed read builds the window first, then marks read only through what it showed (before bounds it) and marks seen only the acks it showed, so a before read or a refused read never swallows an undelivered reply. One-line questions name their prompt (clipped to 120).
  • search never makes a project: a never-seen folder (or a git timeout) answers no results with a note. The limit says at most 50.
  • after with nothing new stays the same size at 60 and 120 messages: only questions whose state changed since the cursor are listed.
  • Answers are whole JSON strings (line breaks kept).
  • The answers section is cut by its exact grammar, so feedback and skills blocks after it stay.
  • The 12 KB budget skips a reply that doesn't fit (continue).
  • The person's newest message is never cut.
  • A person's message with to reads "to you" or "to another session (…)".
  • The Shown line counts what a range read shows. A question-only line names its first prompt. A message_id from another thread beside thread_id is refused.
  • The result helpers moved to inbox-mcp-result.ts, which breaks the search ↔ mcp import cycle.

Tests

  • packages/server/inbox-mcp-window.test.ts covers:
    • a size budget on a 60-message thread, plus a growth bound per added message;
    • limit, expand, message_id, before and after;
    • the 16 KB cut;
    • the 12 KB cap on the person's earlier messages;
    • format: "full";
    • a seeded property run of 300 random windows over threads with every question state (sent, skipped, picked, replaced, withdrawn, open, closed by Mark read); no state is ever missing from the JSON or the text;
    • rendering with and without the mark, including an older connection's text plus JSON;
    • search: results, the project scope, all_projects, limit, refusals, and that a search writes nothing.
  • inbox-mcp-size.test.ts is updated for the window.
  • The harnesses each read a 39-message thread and search through plannotator_inbox:
    • the mod's inbox.test.ts, against a real Inbox;
    • Pi's inbox.test.ts, on the real Pi with the scripted model;
    • OpenCode 2's inbox-v2.test.ts, which runs in CI only (no opencode2 here).
  • Local runs:
    • bun test packages/server/inbox apps/hook packages/shared/inbox packages/core apps/pi-extension/inbox.test.ts: 2,016 pass.
    • bun run typecheck passes.
    • Playwright on the compiled binary: inbox-attachments, inbox, inbox-replaced, inbox-ack, inbox-thread-folding, 45 pass. The sent_sha256 check in inbox-attachments.spec.ts now reads the window's attachments route.

- read_thread reads a thread as a window: the questions still waiting on
  the person (key, state, prompt, choices), the newest `limit` messages in
  full (default 6), the person's earlier messages in full up to 12 KB
  (without their answers sections, whose answers are on the questions), and
  every other earlier message as one line with its questions' states and
  answers. Bodies over 16 KB are cut with a marker naming expand. New
  arguments: expand, before, after (a message id or a cursor), format:
  "full" for the old records; message_id shows that message in full.
  Messages keep the record field names and drop the bookkeeping.
- read_thread, search and wait_for_reply mark their results
  `_meta["ai.plannotator/text-complete"]` and carry a complete transcript
  as text; inboxToolResultText (and the mod's contract copy) then hands the
  model the text alone. An older connection still appends the trimmed JSON.
- search: the agents' read-only search over the ⌘K index (approval
  "inbox-agent-search"), in the caller's project unless all_projects;
  compact rows; writes nothing.
- The plannotator_inbox tool gains search (bundled list regenerated); its
  measured cost on Pi is 7,328 bytes, so the window says about 7 KB,
  roughly 2,000 tokens.

A seeded 60-message thread, as the hosts hand it to the model: 99,971 bytes /
34,689 o200k tokens before, 18,848 / 6,658 after.

Docs: inbox --help, the marketing reference, AGENTS.md, the Pi and OpenCode
READMEs. Tests: packages/server/inbox-mcp-window.test.ts (size budget,
growth bound, window semantics, a property test that no question state is
lost, both renderings, search), the mod, Pi and OpenCode 2 harnesses read a
long thread and search through their tool.
…uestions name their prompt

read_thread marked the whole thread read (and every settled 👍 seen) before
building the window, so a read with before: <id> marked a newer reply it left
out as read (the wake dropped it, the row lost unread), a refused read (bad
expand/before/after) marked everything read, and after: <cursor> marked a 👍 on
an older message seen without showing it. Build the window first, mark read
only up to before, and mark seen only the acks of messages shown.

A one-line message's questions listed only key, state and answer, and the
person's earlier replies drop their answers section, so an answer like "Yes"
no longer said what it answered. Lines and thread.questions now carry the
prompt (clipped to 120 characters).
- search looks projects up without making one (findProjects): a folder the
  Inbox has never seen answers no results with a note, and a git timeout
  answers no results saying so, never project_unresolved. Its limit says
  "at most 50".
- `after` with nothing new stays the same size: a question of a message
  older than the cursor is listed only when its state changed since (its
  question line, or the archive); open and picked ones are in the header.
- Answers are shown whole, as JSON strings (line breaks kept), never clipped
  or flattened.
- withoutAnswersSection cuts only the answers section, by the grammar
  formatQuestionAnswersSection writes; feedback and a skills block after it
  (with # headings in its SKILL.md) stay byte for byte.
- The person's earlier-message budget skips a reply that does not fit and
  goes on with older ones; the person's newest message is always whole.
- A person's message addressed to one session reads "to you" or "to another
  session (…)" (`to` on the message and the line).
- The Shown line counts what a range read shows; a question-only message's
  line names its first prompt; message_id from another thread beside
  thread_id is refused.
- The result helpers move to inbox-mcp-result.ts, so inbox-mcp-search.ts no
  longer imports inbox-mcp.ts at runtime.

Tests in inbox-mcp-window.test.ts for each; the property test now allows a
question an `after` read leaves out only when nothing changed it since the
cursor.
@backnotprop
backnotprop merged commit de83872 into main Oct 20, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant