Why this matters
Tonight a worker reading a 542KB source file in chunks burned 638k input tokens and died with zero workspace changes — pure read starvation. The step cap cannot help (one step has no cost ceiling), and the 75%-consumed pacing notice is evaluated between steps, so one huge read jumps 60%→dead without ever crossing the warning band. Budget awareness already shipped (#6194) and did not help.
Design (from the harness comparison, codex-rs citations)
Adopt codex-rs's placement rule: truncation at capture time, not accounting after insertion (refs/codex/codex-rs/core/src/exec.rs:719-728; default 1 MiB DEFAULT_OUTPUT_BYTES_CAP at utils/pty/src/lib.rs:14):
- In
crates/tui/src/tools/subagent/, intercept each child tool result before it is appended to the child's history; hard-truncate to a byte cap (1 MiB default) with a truncated: true marker the model can see.
- Add a model-facing
max_output_tokens param defaulting to 10k (codex unified_exec/mod.rs:79, tools/handlers/shell_spec.rs:61).
- Evaluate the budget pacing check against the pending result size pre-insertion, so a single call can never jump the budget silently.
Full comparison with citations: codewhale-ops/designs/HARNESS-COMPARISON-20260916.md (parallel doc; will land with the slice).
Acceptance criteria
Related
Why this matters
Tonight a worker reading a 542KB source file in chunks burned 638k input tokens and died with zero workspace changes — pure read starvation. The step cap cannot help (one step has no cost ceiling), and the 75%-consumed pacing notice is evaluated between steps, so one huge read jumps 60%→dead without ever crossing the warning band. Budget awareness already shipped (#6194) and did not help.
Design (from the harness comparison, codex-rs citations)
Adopt codex-rs's placement rule: truncation at capture time, not accounting after insertion (
refs/codex/codex-rs/core/src/exec.rs:719-728; default 1 MiBDEFAULT_OUTPUT_BYTES_CAPatutils/pty/src/lib.rs:14):crates/tui/src/tools/subagent/, intercept each child tool result before it is appended to the child's history; hard-truncate to a byte cap (1 MiB default) with atruncated: truemarker the model can see.max_output_tokensparam defaulting to 10k (codexunified_exec/mod.rs:79,tools/handlers/shell_spec.rs:61).Full comparison with citations:
codewhale-ops/designs/HARNESS-COMPARISON-20260916.md(parallel doc; will land with the slice).Acceptance criteria
truncated: trueand its context grows by ≤ the capcargo test -p codewhale-tui --libfor the touched modules quotes real countsRelated