fix(server): bound provider command output #9291
main fromrefs/pull/9291/head·opened View on GitHubWhat changed#
- Cap provider CLI stdout and stderr collection at 8 MiB each by default.
- Fail provider commands explicitly when either stream exceeds its limit.
- Preserve explicit smaller
maxBytesoverrides and avoid retrying deterministic overflow failures.
Why#
Provider probes shared a collector with no default output limit. A misbehaving CLI could therefore retain arbitrary stdout or stderr in the server process.
The provider collector now uses the same 8 MiB per-stream default as ProcessRunner. It drains both streams before reporting overflow so child processes can exit normally, including on Windows. Parsers never receive truncated JSON, version, or model output as a successful command result.
Verification#
- 62 focused provider tests pass.
- Server typecheck passes.
- Targeted lint and formatting checks pass.
- The regression test exceeds the default limit across three chunks, verifies all chunks were drained, and receives
ProviderCommandOutputLimitError. - The OpenCode process test writes 2 MiB to both stdout and stderr with a 64-byte limit and exits with an explicit overflow error.
Checklist#
- This PR is focused on one reliability issue
- I explained what changed and why
- Before/after screenshots are not applicable because this PR has no UI changes
- A video is not applicable because this PR has no animation or interaction changes
Model: gpt-5.6-sol Harness: Codex in T3 Code
Note
Medium Risk Touches shared provider probing and OpenCode inventory retry behavior; mis-sized limits could break legitimate large CLI output, but the change hardens memory use on a security-sensitive server path.
Overview
Caps provider CLI stdout/stderr collection at 8 MiB by default (with optional smaller maxBytes), replacing unbounded collectStreamAsString with collectProviderCommandOutput and a ProviderCommandOutputLimitError when either stream exceeds the budget. The collector still drains child output after the limit so processes can exit cleanly.
Cursor and OpenCode command paths now use the shared helper. Oversized agent about output surfaces as a health-check error instead of being parsed. OpenCode fails on limit breaches (no silent truncation), skips retries for output-limit failures during CLI inventory, while keeping model inventory when skill discovery alone overflows.
Summary by CodeRabbit#
- Bug Fixes
- Provider health checks now report a clear error when command output exceeds the supported 8 MiB limit.
- Oversized command responses are handled consistently across providers, preventing incomplete output from being parsed as valid data.
- Inventory checks no longer repeatedly retry commands that fail because their output exceeds the limit.
- Command execution continues draining output before reporting size-limit failures, improving process cleanup and diagnostics.
- 1
Codex Review Summary#
This comment shows the latest Codex review activity on this pull request.
Review Status Commit Review trigger 📝 Code Review ✅ Completed 2026-09-03T00:28:08.097439Z 6d1fd2cManual 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.
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
💡 Codex Review#
Here are some automated review suggestions for this pull request.
Reviewed commit:
3de6e1ac00ℹ️ 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".
apps/server/src/provider/providerSnapshot.ts lines 263 to 264OutdatedResolvedby Lucenx9(GitHub profile, opens in a new tab)@@ -257,4 +258,7 @@257258 stream: Stream.Stream<Uint8Array, E>,258259 options?: { readonly maxBytes?: number | undefined },259260 ): Effect.Effect<string, E> =>260- collectUint8StreamText({ stream, ...options }).pipe(Effect.map((collected) => collected.text));261+ collectUint8StreamText({262+ stream,263+ maxBytes: options?.maxBytes ?? DEFAULT_PROVIDER_COMMAND_MAX_OUTPUT_BYTES,264+ }).pipe(Effect.map((collected) => collected.text));Propagate provider output truncation
When a successful provider command emits more than 8 MiB, this wrapper discards
CollectedUint8StreamText.truncatedand returns the truncated text as a normal success. Downstream consumers therefore cannot distinguish valid output from a cut response; for example,GrokSkills.ts:118parses the result as JSON, so a large but validgrok inspect --jsonresponse becomes an empty skill catalog. Return truncation metadata or fail the command on overflow instead of silently passing partial output to parsers.Useful? React with 👍 / 👎.
Fixed in
6d1fd2ce. The shared command collector now drains both stdout and stderr, checks the truncation metadata, and returnsProviderCommandOutputLimitErrorbefore any parser receives partial output. Explicit smaller limits still apply, and OpenCode does not retry this deterministic failure.The regression coverage includes the Grok/shared path, Cursor
agent about, a real child process writing 2 MiB to both streams with a 64-byte cap, and an assertion that oversized OpenCode skill discovery runs only once. The focused suite passes 62/62.Approvability#
Verdict: Not approved
Macroscope's review found this PR not approvable — This focused reliability fix changes existing provider command behavior by introducing an 8 MiB default output limit and explicit failures for oversized output, including during health checks and inventory discovery. Because that runtime default changes product behavior, the change warrants human review.
Not approved because:
- Monthly spending limit reached (workspace setting). Approvability relies on correctness review in order to determine eligibility
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XS
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Verification evidence#
Tested commit
6d1fd2ce.The review regression first went red because an oversized command still returned success:
Test Files 1 failed (1) Tests 1 failed | 4 passed (5)On the published commit:
./node_modules/.bin/vp test run apps/server/src/provider/providerSnapshot.test.ts apps/server/src/provider/Layers/GrokProvider.test.ts apps/server/src/provider/Layers/CursorProvider.test.ts apps/server/src/provider/Drivers/GrokSkills.test.ts apps/server/src/provider/opencodeRuntime.inventory.test.tsTest Files 5 passed (5) Tests 62 passed (62)The focused tests prove these boundary conditions:
- A mock provider emits 8 MiB plus two bytes across three chunks. Collection reads all three chunks, then returns
ProviderCommandOutputLimitError. - A real child process writes 2 MiB to both stdout and stderr with a 64-byte limit. Both streams drain and the command returns an explicit overflow error.
- OpenCode records one oversized skill-discovery invocation, proving the deterministic overflow is not retried.
- Cursor rejects oversized
agent aboutoutput instead of parsing the truncated response.
Server typecheck, targeted lint, formatting, and
git diff --checkall exit successfully. The latest GitHub Actions run verifies the published branch.- A mock provider emits 8 MiB plus two bytes across three chunks. Collection reads all three chunks, then returns
✅ Action performed
Review finished.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Team
Run ID:
2b4b6e35-18de-44d7-9607-552a947a7efc📥 Commits
Reviewing files that changed from the base of the PR and between 2971ec3209d7ef1b00d7ded70fe6342816b1539f and 6d1fd2ce303220fc5ee6ec688ffa486a21b33fe4.
📒 Files selected for processing (6)
apps/server/src/provider/Layers/CursorProvider.test.tsapps/server/src/provider/Layers/CursorProvider.tsapps/server/src/provider/opencodeRuntime.inventory.test.tsapps/server/src/provider/opencodeRuntime.tsapps/server/src/provider/providerSnapshot.test.tsapps/server/src/provider/providerSnapshot.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
Provider command output collection now enforces an 8 MiB limit across stdout and stderr. Cursor and OpenCode integrations use the bounded collector. OpenCode inventory retries skip output-limit failures. Tests cover stream draining, error reporting, and retry behavior.
Changes#
Provider command output handling
Layer / File(s) Summary Bounded output collection
apps/server/src/provider/providerSnapshot.ts,apps/server/src/provider/providerSnapshot.test.tsAdds the 8 MiB default limit and ProviderCommandOutputLimitError.spawnAndCollectdrains stdout and stderr concurrently and reports truncated output after collection.Provider integrations
apps/server/src/provider/Layers/CursorProvider.ts,apps/server/src/provider/Layers/CursorProvider.test.ts,apps/server/src/provider/opencodeRuntime.ts,apps/server/src/provider/opencodeRuntime.inventory.test.tsCursor and OpenCode commands use combined bounded output collection. OpenCode inventory retries non-limit failures but does not retry output-limit failures. Tests cover oversized output, invocation count, and Cursor health-check errors. Estimated code review effort: 3 (Moderate) | ~20 minutes
Merge Risk: ⚪ Minimal · up to
6d1fdThe change bounds provider command output and reports deterministic overflow failures without introducing a demonstrated correctness or availability issue; no actionable merge-blocking risk remains beyond normal checks and review.
Suggested reviewers:
juliusmarminge,maxwellyoung,maria-rcks🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
Check name Status Explanation Resolution Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold. ✅ Passed checks (4 passed)
Check name Status Explanation Title check ✅ Passed The title clearly and concisely describes the main change: bounding provider command output in the server. Description check ✅ Passed The description explains what changed, why it changed, verification results, and checklist status. The UI Changes section is omitted appropriately because the PR has no UI changes. Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request. Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request. - Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
Comment `@coderabbitai help` to get the list of available commands.Codex Review: Didn't find any major issues. More of your lovely PRs please.
Reviewed commit:
6d1fd2ce30ℹ️ 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".
Lucenx9(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
copilot-pull-request-reviewer[bot](GitHub profile, opens in a new tab) reviewed
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.