Skip to content

chore(tools): Cap tool diagnostic output - #888

Merged
JeanMertz merged 3 commits into
mainfrom
cargo-test-trace
Jul 27, 2026
Merged

chore(tools): Cap tool diagnostic output#888
JeanMertz merged 3 commits into
mainfrom
cargo-test-trace

Conversation

@JeanMertz

Copy link
Copy Markdown
Collaborator

Add a shared truncate helper in .config/jp/tools and apply it to every subprocess stream that ends up in a tool result: cargo check, cargo fmt, cargo test, cargo expand, and the generic unix-utils runner. Each cap is sized to the content it bounds: 32 KB for compiler and linter diagnostics, 100 KB for expanded macro source (the payload the caller asked for), and 8 KB per failing test's captured output (a run can report many failures, each contributing its own block). A single failing derive macro can otherwise produce tens of thousands of near-identical diagnostics, blowing well past a provider's context limit.

Add RFD D24 (docs/rfd/drafts/D24-bounded-tool-output.md), which proposes a size_threshold config key resolved per-tool through conversation.tools, plus a non-configurable hard ceiling applied to every tool response before it is persisted to the conversation stream. The bounding done here covers only the first-party cargo_* tools; MCP servers, user-defined local tools, and coordinator-synthesized responses remain unbounded, which is what caused a real conversation to become unusable after a 1,293,623-token tool response was written to its stream and re-sent on every subsequent turn.

Add a shared `truncate` helper in `.config/jp/tools` and apply it to
every subprocess stream that ends up in a tool result: `cargo check`,
`cargo fmt`, `cargo test`, `cargo expand`, and the generic unix-utils
runner. Each cap is sized to the content it bounds: 32 KB for compiler
and linter diagnostics, 100 KB for expanded macro source (the payload
the caller asked for), and 8 KB per failing test's captured output
(a run can report many failures, each contributing its own block).
A single failing derive macro can otherwise produce tens of thousands
of near-identical diagnostics, blowing well past a provider's context
limit.

Add RFD D24 (`docs/rfd/drafts/D24-bounded-tool-output.md`), which
proposes a `size_threshold` config key resolved per-tool through
`conversation.tools`, plus a non-configurable hard ceiling applied to
every tool response before it is persisted to the conversation stream.
The bounding done here covers only the first-party `cargo_*` tools;
MCP servers, user-defined `local` tools, and coordinator-synthesized
responses remain unbounded, which is what caused a real conversation
to become unusable after a 1,293,623-token tool response was written
to its stream and re-sent on every subsequent turn.

Signed-off-by: Jean Mertz <git@jeanmertz.com>
Signed-off-by: Jean Mertz <git@jeanmertz.com>
Signed-off-by: Jean Mertz <git@jeanmertz.com>
@JeanMertz
JeanMertz merged commit 1e5da87 into main Jul 27, 2026
16 checks passed
@JeanMertz
JeanMertz deleted the cargo-test-trace branch July 27, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant