chore(tools): Cap tool diagnostic output - #888
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a shared
truncatehelper in.config/jp/toolsand 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 asize_thresholdconfig key resolved per-tool throughconversation.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-partycargo_*tools; MCP servers, user-definedlocaltools, 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.