
Key takeaways
- Part 5 sets default budgets for shell, test, search, diff, and MCP output, expanding only when evidence demands it
- Long output can remain in a session and return on later turns, making early bounds disproportionately useful
- A practical starting point is 50 search paths, roughly 30 failure-log lines, summaries for passing tests, and diff stats before hunks
- Track repeated calls and diagnostic success because a hidden cause can erase any saving
- This part produces
tool-budget.md, whose escalation signals feed Part 6's model routing
Tool output is the largest handoff payload
-
A short handoff does not undo an unbounded log already loaded into the session
- Full test output, minified stack traces, and thousands of search matches are common sources
- Control output volume before optimizing command count
-
Use a wide-to-narrow diagnostic funnel
- Find filenames, symbols, or error-code locations first
- Open nearby context from the strongest candidates second
- Read the full range only when it can distinguish competing hypotheses
-
Anthropic recommends trimming long logs to the relevant section or roughly the last 20–30 lines1
- Treat that number as an initial diagnostic window rather than a universal hard cap
- Expand a named range when the earliest cause or a failure chain falls outside it
Set a default budget by output type
-
Bound both search result count and fields
- Start with 50 file paths or 30 text matches including line numbers
- Narrow by extension, path, or symbol before asking for more results
-
Make tests failure-first
- On success, retain the command, pass count, and duration
- On failure, read one message and about 20–30 stack lines before the next failure
- Run the full suite for completion, but do not paste its complete success stream
-
Move from diff size to content progressively
- Inspect
git diff --statand changed files first - Review relevant hunks second
- Read the complete diff during final verification, treating generated files separately
- Inspect
| Output | Starting budget | Expand when |
|---|---|---|
| File search | 50 paths | all candidates are irrelevant |
| Text search | 30 matches | the call path is incomplete |
| Failure log | about 30 lines | the first cause is outside the range |
| Passing tests | one summary line | investigating flakiness |
| Diff | stat, then relevant hunks | final review or cross-file effects |
| Web or MCP | relevant fields per question | evidence conflicts or is incomplete |
- These are author-defined starting values
- A compiler error and a distributed trace need different windows
- Tune the values against real missed diagnoses
Use client-side output controls
-
Gemini CLI can assign a token budget to shell-output summarization2
model.summarizeToolOutput.run_shell_command.tokenBudgetbounds the summary- Preserve where the raw log lives and how to query it because summarization can omit an important row
-
Codex MCP configuration supports tool allowlists and per-tool output token limits3
enabled_toolscan remove irrelevant tools and their accidental invocation pathstools.<tool>.output_token_limitis particularly useful for large search or issue responses
-
MCP tool instructions also consume context
- OpenAI says the first 512 characters of server
instructionsshould make sense on their own3 - Put essential constraints first and move long examples into on-demand documentation
- OpenAI says the first 512 characters of server
Detect over-truncation through retry cost
-
Record total output and repeated diagnosis together
- Add
tool_output_lines,tool_calls,repeated_calls, andtime_to_first_hypothesis - Three widening reruns of the same command suggest that its initial window may be too small
- Add
-
A successful budget improves completed-work output without lowering diagnostic quality
- Median output per completed task should fall
- Time to the first correct hypothesis and test pass rate should not worsen
- Human time spent reopening truncated logs must not rise
-
Sensitive-data removal remains a separate, stronger constraint
- Remove credentials, personal information, and private URLs before summarization
- A shorter output is not automatically safe to send to an external model
Hand difficulty signals to the next part
-
Record both the default budget and the conditions that expand it in
tool-budget.md- Failures across packages, non-reproducible errors, and a third failed hypothesis signal higher difficulty
- A single file, clear error, and one verifier signal a lightweight-model candidate
-
Part 6 does not choose a stronger model merely because raw output is large
- Narrow the output first, then route on the remaining reasoning difficulty
- Escalate only at observable events such as two failed verification hypotheses
Action plan
- Identify the five noisiest commands and document their default window and exact requery command
- Enable only task-relevant MCP tools and cap the largest responses first
- If ten tasks show lower output but more retries or slower diagnosis, restore one budget level
Footnotes
-
Anthropic, models, usage, and limits in Claude Code — recommends trimming long logs to relevant sections ↩
-
Google, Gemini CLI configuration — documents shell-output summarization and
tokenBudget↩ -
OpenAI, Model Context Protocol in Codex — documents tool allowlists, per-tool output limits, and server instruction guidance ↩ ↩2
Related articles
A Subscription-First AI WorkspaceRoute subscription work from light to deep modelsClassify work as exploration, everyday implementation, or high-stakes reasoning, then start with the lightest suitable model and escalate only on observable failure signals.
A Subscription-First AI WorkspaceHandoff AI work without carrying the sessionStart a fresh session for a new task, compact only a continuing task, and switch providers with evidence-based handoffs instead of copied conversation history.
A Subscription-First AI WorkspacePut a budget on AI coding contextReduce repeated subscription usage by separating durable rules, task contracts, and temporary evidence instead of duplicating long AGENTS.md, CLAUDE.md, and GEMINI.md files.