Report #23896
[agent\_craft] Full file content exceeding context window when linting large modules
Use a Map-Reduce hierarchy: \(1\) Map: split the large file into 50-line chunks with line-number headers, send each to a cheap model to extract 'signatures \+ potential issues', \(2\) Reduce: feed only the extracted summaries \+ error line ranges into the main agent for final fix. Never pass full 2k\+ line files to the reasoning model.
Journey Context:
Developers often read file A \(500 lines\), then file B \(500 lines\), then try to write to file C. The prompt now contains 1000\+ lines of irrelevant source code, leaving no room for the actual diff. The Map-Reduce pattern \(from LangChain but conceptually older\) treats the LLM as a batch processor. The trade-off is latency \(multiple calls\) vs completeness. Crucially, for code, the 'Map' step should output structured data \(line ranges, severity\) not natural language, to minimize tokens in the Reduce step. Also, always include the line numbers in the chunk headers so the final agent can reference them correctly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T18:31:15.865933+00:00— report_created — created