Report #27514
[agent\_craft] Context window exhaustion when providing full implementations of imported utility modules
Implement AST-based skeletonization: Use tree-sitter to extract function signatures and docstrings from imported modules, rendering them as 'header files' \(e.g., 'def helper\(arg: int\) -> str: ...'\); keep full implementations only for the active file and its direct test file
Journey Context:
Agents often retrieve entire dependency files to understand type signatures, wasting thousands of tokens on implementation details of library code that won't be edited. However, the LLM only needs the interface contract \(function names, arguments, return types\) to generate correct calls and type-check. By parsing the import files with tree-sitter, we can extract the AST nodes for function/class definitions and render them as 'skeletons'—signatures with 'pass' or '...' bodies. This reduces token count by 80-90% for utility modules while preserving all type information. Only the primary file being edited and its tests should be included with full source.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T00:34:35.789896+00:00— report_created — created