Skip to content

fix: report PROTOCOL_ERROR when an older host sends a response over the cap - #322

Merged
ThomasK33 merged 6 commits into
mainfrom
fix/rpc-client-over-cap
Nov 4, 2026
Merged

ThomasK33 merged 6 commits into
mainfrom
fix/rpc-client-over-cap

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Why

The advisor on #320 asked for three last changes:

  1. sendRpc has its own over-cap check, and only an older host (without fix: accept RPC responses up to 64 MiB and refuse a larger success with PROTOCOL_ERROR #320's server check) can reach it. That check still reported RPC_ERROR "RPC response exceeds maximum buffer size." with retryable: true. A retry gets the same size, so it must not say retryable.
  2. The MAX_RPC_RESPONSE_CHARS comment must state how much memory the CLI needs for a response near the cap. If the peak goes over about 1.5 GB, the cap must come down.
  3. docs/USAGE.md must say what a response over the cap gives.

What changed

  • src/host/rpcClient.ts: the over-cap path reports PROTOCOL_ERROR "RPC response is over the 67108864-character limit.", with method, socketPath and maxResponseChars in details. makeCliError marks PROTOCOL_ERROR as not retryable. The exit code stays 9.
  • src/protocol/messages.ts: the MAX_RPC_RESPONSE_CHARS comment gives the measured CLI memory. The cap stays at 67,108,864.
  • docs/USAGE.md (Exit Codes) and src/host/README.md describe the failure.

Memory measurement

I used live sessions on #320's head 17e4ffe and process.resourceUsage().maxRSS in the CLI process, from a preload hook.

Snapshot Response line CLI peak RSS
80x24 styled, --include-cells about 109,000 characters 227 MiB (the baseline)
1,000x1,000 styled, --include-cells (999,999 styled cells) 56,051,020 characters 819 MiB and 963 MiB in two runs

So the CLI needs about 14 bytes per response character above its baseline. A response at the cap takes about 1.1 GiB, which is under 1.5 GB, so the cap stays. The CLI wrote 134 MB of JSON for the 1,000x1,000 snapshot in about 7 s.

The session host's peak RSS for the same snapshot went from 340 MiB to 1.75 GiB (VmHWM). The cap does not change that number. The host builds and serializes the whole result before its size check, as it did before #320, when the CLI dropped the response.

Behavior changes for CLI and JSON users

A CLI talking to a host from before #320 now reports a response over the cap as exit 9 PROTOCOL_ERROR with retryable: false and details.maxResponseChars. Before, it reported exit 9 RPC_ERROR with retryable: true.

Verification

Refs #320


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: xhigh

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T04:53:38.007412Z 344c5c1 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 031b2936fd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/USAGE.md Resolved
@ThomasK33 ThomasK33 changed the title fix: report PROTOCOL_ERROR when an older host sends a response over 64 MiB fix: report PROTOCOL_ERROR when an older host sends a response over the cap Nov 4, 2026
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 344c5c16f4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ThomasK33
ThomasK33 added this pull request to the merge queue Nov 4, 2026
Merged via the queue into main with commit c1bb09c Nov 4, 2026
18 checks passed
@ThomasK33
ThomasK33 deleted the fix/rpc-client-over-cap branch November 4, 2026 05:27
@github-actions github-actions Bot mentioned this pull request Nov 4, 2026
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