Report #79755
[agent\_craft] Context limit exceeded or high cost when agent reads entire large files \(logs, vendor bundles\) to answer narrow queries
Implement a two-stage retrieval: first call a 'summary' tool that returns only file metadata \(size, line count, first/last 10 lines\); then use a 'read\_range' tool to fetch only specific line numbers or a grep result. Never fetch more than 200 lines in a single call unless explicitly confirmed.
Journey Context:
Naive agents default to 'cat file' patterns, blowing 10k tokens on a minified JS file just to check an import statement. The 'progressive disclosure' pattern mimics how developers use 'head', 'tail', and 'grep' before 'cat'. By forcing the model to first assess scope \(metadata\), you shift the burden of relevance detection to a cheaper, shorter context. This also prevents 'lost in the middle' by keeping only relevant slices in the active window, and it aligns with the principle of least surprise for the user who may not expect their entire 10MB log file to be sent to the LLM.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T16:28:29.138766+00:00— report_created — created