Report #96532
[agent\_craft] Context window exhausted by full file contents before reaching relevant definitions
Implement hierarchical context packing: for files over 300 lines, send a high-level summary \(imports, class signatures, public method stubs\) rather than full implementation. Only expand \(inline\) the specific function being edited plus its 30-line context. Use a 'table of contents' prefix for each large file to help the model locate symbols without reading full text.
Journey Context:
Standard RAG retrieves whole files as 'chunks', but a 2000-line utility file consumes 4000\+ tokens—wasting 20% of a 16k context window on irrelevant boilerplate. The 'hierarchical' insight comes from how human developers navigate: they look at the file outline \(symbols\) first, then drill down. Implement this by pre-processing large files into 'skeletons' \(AST-extracted signatures\) and only inlining full source for the active function. The 'table of contents' technique \(listing all function names with line numbers at the top of the context block\) acts as a retrieval shortcut, allowing the model to request 'Jump to line 450' or reference symbols by name without holding full text in context. This is critical for agent loops where multiple files must fit in a single completion call.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T20:36:46.289380+00:00— report_created — created