fix(agent-core): cap background shell output to match foreground#1372
Conversation
🦋 Changeset detectedLatest commit: e8777fc The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 385e6a7ec7
ℹ️ 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".
| if (!entry.outputLimitTripped && entry.outputSizeBytes > MAX_TASK_OUTPUT_BYTES) { | ||
| entry.outputLimitTripped = true; | ||
| void this.stop(entry.taskId, foregroundOutputLimitReason()); | ||
| void this.stop(entry.taskId, outputLimitReason()); |
There was a problem hiding this comment.
Restrict the output cap to process tasks
Because appendOutput is the common sink for AgentBackgroundTask and QuestionBackgroundTask as well as shell processes, this unqualified cap now also fires for detached subagent/user-question results. Those tasks append their completed result in one call and then settle as completed, so a >16 MiB result sets outputLimitTripped, returns before appendTaskOutput, and leaves TaskOutput/notifications without a persisted full log even though the task completed. Please scope the shell-output ceiling to process tasks, or keep non-shell task results persisted.
Useful? React with 👍 / 👎.
Background (detached) shell commands were exempt from the 16 MiB output ceiling, so a runaway background command could fill the disk or crash the process. Apply the same cap to background shell commands and stop feeding the disk write chain once it trips. Scope the ceiling to process tasks so subagent and user-question results, which are appended once and must be persisted, are left untouched.
385e6a7 to
e8777fc
Compare
Related Issue
No related issue. This is a follow-up to #1285, which capped foreground shell output at 16 MiB but left background (detached) commands exempt.
Problem
Background (detached) shell commands were not subject to the 16 MiB output ceiling that protects foreground commands. A runaway background command — for example one that prints tens of millions of lines — would stream its entire output into the persisted
output.logand the in-memory disk-write chain with no bound, which can fill the disk or crash the process with an out-of-memory error. Foreground commands have been force-terminated at 16 MiB since #1285; background commands should behave the same.What changed
Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.