Repository navigation
fix(mcp): name response-byte and startup ceilings in recovery - #6005
Conversation
Name REA_MCP_MAX_RESPONSE_BYTES, its effective value, the 10485760 byte floor, and process restart when the stdio response budget is hit, and state that the setting does not raise Node's string ceiling. Name fixed MCP startup phase budgets when those deadlines fire, and keep Codex's 30 second startup figure as client guidance. Co-authored-by: morluto <morluto@users.noreply.github.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3e279a61b0
ℹ️ 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".
[Medium impact] The PR appears safe to merge; no outstanding blocking issue was identified. SummaryThe PR names MCP response limits and startup deadlines, improves recovery guidance, and keeps oversized SDK errors readable.
Reviews (3) · Last reviewed commit: "style(mcp): format the SDK diagnostic pr..." · Reviewed by Greptile |
Name REA's reserved string limit separately from Node's ceiling, restore detail:summary discovery for an oversized complete evidence bundle, and apply the doctor deadline sentence when binary_session itself times out. Co-authored-by: morluto <morluto@users.noreply.github.com>
Keep detail:summary discovery, the reserved-versus-Node string ceiling, the binary_session doctor deadline, and startup probe failure coverage alongside main's fixed-allowance remediation. Co-authored-by: morluto <morluto@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 13de9bca98
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Quoted SDK validation diagnostics expand when recovery JSON is escaped into MCP text. Shorten only that preview so the retained-evidence reference still arrives as parseable error content. Co-authored-by: morluto <morluto@users.noreply.github.com>
An oversized get_evidence_bundle summary no longer repeats detail: summary. export_evidence_bundle still writes the retained bundle outside one MCP frame, including when a larger byte budget cannot raise the string ceiling. Co-authored-by: morluto <morluto@users.noreply.github.com>
oxfmt rejected the fitted-preview ternary in EvidenceMcpServer.ts, which failed Static checks and the CI required gate. Co-authored-by: morluto <morluto@users.noreply.github.com>
Summary
Refs #5910 (parent #5808). When the MCP stdio response budget is hit, recovery now names
REA_MCP_MAX_RESPONSE_BYTES, the effective byte value, the 10485760 byte (10 MiB) floor, and that a change requires restarting the REA process. It names REA's reserved single-string limit (MAX_STRING_LENGTH - 1024) separately from Node'sMAX_STRING_LENGTH, and says this setting raises neither.An oversized complete
get_evidence_bundlestill tells the agent to calldetail: summary, theninspect_analysis_view. An oversized summary does not repeat that step. It still namesexport_evidence_bundle, which writes the retained bundle outside one MCP frame. That remains the MCP recovery path when the overflow is a string-length limit a larger byte budget cannot raise.Fixed MCP startup phase budgets are named when those deadlines fire: value, units, and no runtime override. Codex
startup_timeout_secof 30 seconds stays client guidance on the doctor path. REA does not enforce that figure as the doctor deadline. Abinary_sessiontimeout after the catalog uses that same sentence.Oversized SDK validation recovery still returns parseable JSON. When a diagnostic preview of quotes or backslashes would expand past the text budget, only that preview is shortened. The error keeps
reported_limits.evidence_reference.kind: "retained-evidence"when recording succeeds, and the complete diagnostic stays in retained Evidence.Problem and expected behavior
A response that exceeds the stdio budget said to use a larger MCP response budget without naming
REA_MCP_MAX_RESPONSE_BYTES, the floor, or restart. The string-ceiling branch reported REA's reserved limit as Node's ceiling. Oversized complete dossier delivery replaced thedetail: summarynext step with generic CLI JSON guidance.rea mcp doctorreported an expired deadline without the effective milliseconds when the deadline fired duringbinary_sessionafter initialize and the catalog. Packaged startup checks for initialize (15000 ms), tools/list (5000 ms), and first catalog (20000 ms) failed without those values on the probe path.A quoted SDK validation diagnostic (
"\\repeated) made the replacement error's text encoding fail. The transport then removed the structured carrier and sent emptycontent, so the client could not read the retained-evidence reference.An oversized
get_evidence_bundlesummary told MCP-only callers to use CLI JSON.export_evidence_bundlestill works on the same connection, and a string-length overflow is not fixed by raising the byte budget.Change and scope
Wording and projection, plus fitting the SDK diagnostic preview to the MCP text budget. Numeric ceilings are unchanged and no new setting was added.
ToolResultDelivery) and oversized-error replacement (EvidenceMcpServer.recoverError) share one projection. Receive-buffer text names the effectiveREA_MCP_MAX_RESPONSE_BYTESvalue. String-ceiling text names REA's reserved limit and Node's actual ceiling, and says the env var does not raise either. A completeget_evidence_bundlekeeps thedetail: summarydiscovery sentence. An oversized summary drops only that sentence and keeps the sameexport_evidence_bundleclause. Paging or complete CLI JSON stays the next step for the other overflow paths.rea mcp doctorappends the fixed doctor deadline when the deadline, an SDK request timeout, or an abort fires, including abinary_sessionrejection after the catalog. The effective milliseconds are the applied budget (policy default 30000 ms).diagnostic_previewexpands past the text budget under JSON escaping, only that preview is shortened (diagnostic_truncated: true). The wire error remains parseable JSON and keeps the retained-evidence reference.Moonshot's 13312 byte schema budget and the compact schema depth of 10 do not fail the call; compact presentation reduces the advertisement. No new error was added for them.
Analysis-view, environment, and HTTP admission caps in the same inventory theme were left unchanged. They either truncate with an existing limitation or fail through a mixed refusal, and this PR does not spray wording into those directories.
Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.
Not applicable. This is recovery text for existing MCP budgets. It does not add a provider, target execution, injection, mutation, or protection recovery.
Contract and boundary impact
src/server/toolResult.ts,src/server/EvidenceMcpServer.ts).src/config/mcpResponseBudget.tsowns the stdio budget facts.src/server/toolResultEncoding.tsowns the reserved string limit versus Node's ceiling.src/mcpStartupPolicy.tsandsrc/mcpDoctor.tsown startup-deadline recovery. The packaged probe repeats that sentence because it cannot import the TypeScript module.src/domain/analysisErrorPresentation.tsowns the shared discovery and export sentences.docs/mcp-contracts.mdnow says the response-byte setting is read at process start and does not raise the reserved string limit or Node's ceiling.docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs andskills/; edit authored instructions in.agents/skills/reverse-engineer-anything/and never commit build outputs): none. Skill text was not changed.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
tests/conformance/contracts/mcpResponseBudget.test.ts,tests/boundary/mcp/largeToolResult.test.ts,tests/boundary/mcp/mcpDoctor.test.ts,tests/boundary/mcp/mcpStartupPolicy.test.ts,tests/boundary/mcp/analysisViewMcp.test.ts, plus the existing oversized-error delivery test. The quoted SDK diagnostic case insrc/server/EvidenceMcpServer.test.tsis the regression for empty error content. The summary-overflow case now requiresexport_evidence_bundleand rejects a repeateddetail: summary.get_evidence_bundle and detail: summaryand received only the generic CLI JSON sentence. String-ceiling text reportedMCP_RESULT_STRING_LIMITas Node's ceiling. The doctor saved a plainbinary_sessionerror when that call passed the deadline after the catalog. Source tests on13de9bca9failed both protocol revisions inexpectEscapedSdkDiagnosticRetentionbecausecontentwas empty. An oversized summary's remediation stopped at CLI JSON (discussion_r4339174785).get_evidence_bundle and detail: summaryandREA's reserved single-string limit of <MCP_RESULT_STRING_LIMIT>plusNode's single-string ceiling of <MAX_STRING_LENGTH>. An oversized summary remediation includesexport_evidence_bundleandcaller-selected path, and does not repeatdetail: summary. The doctor hang fixture (applied deadline 60000 ms) includes60000 ms,no runtime override, andCodex startup_timeout_sec of 30 seconds is client guidance. Abinary_sessiontimeout after the catalog uses that same 60000 ms sentence. A quote-heavy SDK validation failure returns aresource_constraintJSON text body withevidence_reference.kindretained-evidence.MAX_STRING_LENGTH; summary overflow uses the same export sentence for both constraints, and the string-ceiling facts are covered by the existing projection test.For evidence-bearing changes:
Validation performed
origin/mainatd8a9673fc. The only conflict wassrc/domain/analysisErrorPresentation.ts: fixed-allowance recovery stays first, and transport overflow still uses thedetail: summarydiscovery sentence.npm run check:fastafter the merge (typecheck and lint succeeded).npx vitest run tests/conformance/contracts/mcpResponseBudget.test.ts— 7 passed.npx vitest run tests/boundary/mcp/largeToolResult.test.ts— 8 passed.npx vitest run tests/boundary/mcp/mcpStartupPolicy.test.ts— 10 passed, including probe phase failures, the first-catalog overrun, and unrelated failures.npx vitest run tests/boundary/mcp/mcpDoctor.test.ts -t "request-flow deadline|child lifecycle"— startup deadline,binary_sessiondeadline, and unrelated request-flow failure passed.npx vitest run tests/boundary/mcp/analysisViewMcp.test.ts— 21 passed, including the oversized dossier discovery case.src/domain/fixedAllowanceRemediation.test.ts(8) andtests/boundary/providers/fixedAllowanceRecovery.test.ts(2) passed after the conflict resolution.33923c55c:npm run check:fast— typecheck and lint succeeded.npm run test:focused -- src/server/EvidenceMcpServer.test.ts tests/boundary/mcp/largeToolResult.test.ts tests/boundary/mcp/analysisViewMcp.test.ts tests/conformance/contracts/mcpResponseBudget.test.ts— 40 passed, including both SDK validation retention revisions.30c6b4b6c:npm run check:fast— typecheck and lint succeeded.npm run test:local -- src/server/EvidenceMcpServer.test.ts— 4 passed, including both public stdio SDK revisions.npm run test:local -- tests/conformance/contracts/mcpResponseBudget.test.ts src/server/toolResultEncoding.test.ts— 17 passed.npm run test:focused -- tests/boundary/mcp/largeToolResult.test.ts tests/boundary/mcp/toolResult.test.ts tests/boundary/mcp/analysisViewMcp.test.ts— 45 passed.largeToolResultwas re-run after the export assertion (8 passed).30c6b4b6cfailedoxfmt --checkinsrc/server/EvidenceMcpServer.ts(the fitted-preview return).CI requiredthen failed becausestaticwas a failure and the lanes that need it were skipped.4e2671b9ewraps that ternary. Behavior is unchanged.4e2671b9e:npm run format:check— all matched files use the correct format.npm run check:fast— typecheck and lint succeeded.npm run test:focused -- src/server/EvidenceMcpServer.test.ts— 4 passed.Real provider workflows were not required. These paths are MCP delivery, doctor, and startup-probe projection.
Compatibility, safety, and release
MCP_RESULT_STRING_LIMITas Node's ceiling will see both numbers. An oversized summary now namesexport_evidence_bundleinstead of CLI JSON alone. Limits and configuration parsing are unchanged. A quote-heavy SDK diagnostic may now include a shorterdiagnostic_previewthan 256 characters;diagnostic_truncatedstays true and the retained record still has the original error.Author readiness
Human owner: @morluto
Before merge
type(scope): outcome.