Skip to content

v0.9.14: cap every child tool result at capture time — 1 MiB bytes / 10k tokens into context, pacing checked at result insertion #6282

Description

@Hmbown

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):

  1. 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.
  2. Add a model-facing max_output_tokens param defaulting to 10k (codex unified_exec/mod.rs:79, tools/handlers/shell_spec.rs:61).
  3. 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

  • A child issuing one tool call whose raw result is >1 MiB receives a truncated result with truncated: true and its context grows by ≤ the cap
  • The pacing/budget check runs at result-insertion time; a test proves a child at 60% cannot die mid-read without having crossed the warning threshold first
  • Focused subagent tests green; cargo test -p codewhale-tui --lib for the touched modules quotes real counts

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreliabilityReliability, flaky behavior, retries, fallbacks, and robustnesssubagentsSub-agent orchestration, lifecycle, and completion handling

    Projects

    • Status
      Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions