Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): bound provider command output #9291

ClosedLucenx9(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/9291/headopened View on GitHub

What 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 maxBytes overrides 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.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 6d1fd2ce303220fc5ee6ec688ffa486a21b33fe4. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

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. Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

    2. chatgpt-codex-connector[bot](GitHub profile, opens in a new tab)commented

      Codex Review Summary

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

      ReviewStatusCommitReview trigger
      📝 Code Review✅ Completed 2026-09-03T00:28:08.097439Z6d1fd2cManual 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.

    3. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    4. 💡 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".

    5. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      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
      Review your spending limits in [Billing settings](https://app.macroscope.com/pingdotgg/settings/billing). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    6. 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.ts
      Test 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 about output instead of parsing the truncated response.

      Server typecheck, targeted lint, formatting, and git diff --check all exit successfully. The latest GitHub Actions run verifies the published branch.

    7. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      ✅ 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.

    8. Review Change Stack

      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.ts
      • apps/server/src/provider/Layers/CursorProvider.ts
      • apps/server/src/provider/opencodeRuntime.inventory.test.ts
      • apps/server/src/provider/opencodeRuntime.ts
      • apps/server/src/provider/providerSnapshot.test.ts
      • apps/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.ts
      Adds the 8 MiB default limit and ProviderCommandOutputLimitError. spawnAndCollect drains 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.ts
      Cursor 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 6d1fd

      The 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 nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring 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 nameStatusExplanation
      Title check✅ PassedThe title clearly and concisely describes the main change: bounding provider command output in the server.
      Description check✅ PassedThe 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✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck 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.
    9. 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".

Sign in to join this conversation.