Conversation
- 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.
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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,
afteras 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):message_id/key,Q<n>, state, prompt and choices.limitmessages in full (default 6).expandcall.expand: [ids]andmessage_idshow messages exactly as sent.before/aftertake a message id or a cursor.format: "full"returns the old records.before/afterleaves out is listed inthread.questions.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.inboxToolResultTextin the contract (the mod's copy too; Pi vendors it) then hands the model the text alone. send_message, submit_guide, resolve_message andformat: "full"are not marked. An older connection ignores the mark and appends the trimmed JSON. The phone proofs' fields (wait_for_replystatus/reply.body, send_messagequestions[].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 unlessall_projects.project_path.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).Tool cost. The
plannotator_inboxentry measured on the real Pi is 7,328 bytes (1,732 o200k tokens). Main's 6,390 was an estimate.INBOX_TOOL_COSTnow 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).
afterwith nothing newafterwith nothing newThe MCP server instructions are 1,981 characters (cap 2,048). The agent tool's description is 1,736.
Review fixes (second and third commits)
beforebounds it) and marks seen only the acks it showed, so abeforeread or a refused read never swallows an undelivered reply. One-line questions name their prompt (clipped to 120).afterwith nothing new stays the same size at 60 and 120 messages: only questions whose state changed since the cursor are listed.continue).toreads "to you" or "to another session (…)".message_idfrom another thread besidethread_idis refused.inbox-mcp-result.ts, which breaks the search ↔ mcp import cycle.Tests
packages/server/inbox-mcp-window.test.tscovers:format: "full";all_projects, limit, refusals, and that a search writes nothing.inbox-mcp-size.test.tsis updated for the window.plannotator_inbox:inbox.test.ts, against a real Inbox;inbox.test.ts, on the real Pi with the scripted model;inbox-v2.test.ts, which runs in CI only (noopencode2here).bun test packages/server/inbox apps/hook packages/shared/inbox packages/core apps/pi-extension/inbox.test.ts: 2,016 pass.bun run typecheckpasses.inbox-attachments,inbox,inbox-replaced,inbox-ack,inbox-thread-folding, 45 pass. Thesent_sha256check ininbox-attachments.spec.tsnow reads the window's attachments route.