Skip to content

mcp(fix): Preserve outcomes and cursors at the frame limit - #194

Merged
tony merged 3 commits into
program-completion-waitfrom
mcp-response-budget
Dec 6, 2026
Merged

tony merged 3 commits into
program-completion-waitfrom
mcp-response-budget

Conversation

@tony

@tony tony commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #180.
Closes #181.

What changed, and why

A retained journal or a page of escaped display fields can exceed the JSON-RPC wire limit. The encoder accounts for the request ID, envelope and newline. A large journal keeps its operation outcome and reports the journal limit. Pagination prepares an encodable response and successor before consuming the cursor. The two issues meet in the frame-size calculation.

Checks run

The STDIO suites ran on pristine tmux 3.3 and upstream 3.8. They poll large journals with distinct request IDs and walk pages whose values expand during JSON encoding.

  • MCP STDIO on tmux 3.3 passed in 11.33 s.
  • MCP STDIO on tmux 3.8 passed in 8.00 s.

Review evidence

The MCP encoder owns the complete response frame, including the request ID. Both operation polling and pane pagination consult it before dropping evidence or consuming a cursor.

With the topic tests and the runtime code from 178ab420b, the focused check failed. Both the oversized journal and the escaped pane page returned a JSON-RPC Response limit exceeded error. The table gives the running time of each complete command on Linux.

Regression Reverted Corrected on 89df3c4ba
Operation outcome Fail, 4.82 s Pass, 4.99 s
Escaped pane page Fail, 1.90 s Pass, 1.90 s

Merge stack

This PR follows #193 in the tested merge order. The comparison shows this PR’s own changes. Stack #206 · Changes in this PR

All six required Linux jobs passed on 89df3c4ba. GitHub records the stack merge at 15b285de9. CI run · Merged commit

Tool use

Codex extracted this change from #169 and ran the checks above on the topic branch. A separate Codex reviewer checked the component boundaries and the two corrected test fixtures.

tony added 3 commits December 5, 2026 19:05
why: A retained workspace journal could fit in memory but exceed the
JSON-RPC response limit. Polling then lost the operation outcome.

what:
- Size the tool response including its encoded request ID and newline.
- Retain the outcome with a journal error when the frame would exceed
  the limit.
- Poll an oversized result over STDIO with two valid request IDs.
why: Up to sixteen escaped pane titles could overflow one JSON-RPC
frame. The adapter discarded the previous cursor before encoding the
page, trapping callers partway through an immutable observation.

what:
- Send the largest ordered prefix that fits the response budget.
- Replace the cursor when its successor and encoded reply are ready.
- Identify display fields omitted at the existing per-field limit.
- Traverse quote-heavy titles and verify cursor scope and replay.
@tony
tony changed the base branch from main to program-completion-wait December 6, 2026 01:07
@tony
tony force-pushed the mcp-response-budget branch from f72df74 to 89df3c4 Compare December 6, 2026 01:08
@tony
tony added this pull request to stack #206 December 6, 2026 01:08
@tony
tony merged commit 15b285d into main Dec 6, 2026
6 of 10 checks passed
tony added a commit that referenced this pull request Dec 6, 2026
why: A tmux hook could add output to a pane or option read. A large
MCP reply could hide an operation outcome or advance a cursor before
the client received the page.

what:
- Fit the Program listener to the server socket path, wake waiters on
  exit, and retry pane removal after a lost reply (#191, #192, #193).
- Keep MCP operation outcomes readable and size pages before advancing
  their cursors. Show the STDIO client reading a result (#194, #195).
- Keep hook output out of pane captures and option reads. Use
  `Pane.wait_for_text/4` in the notebook (#196, #197).
- Check root exit separately from trace delivery in cold-start tests
  (#198).
- Document checkout dependencies, inherited sockets and capability
  APIs (#199, #200, #201).
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.

An oversized observation page consumes its MCP cursor An oversized MCP journal hides the completed operation outcome

1 participant