Dir loop exhausts context budget on small targets #44
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Observation
Smoke testing #5 on the
luminos_libdirectory (13 Python source files, ~2800 LOC, ~200KB on disk) the dir loop hit the context budget early-exit and bailed:MAX_CONTEXT = 180_000andCONTEXT_BUDGET = 0.70 * MAX_CONTEXT = 126_000. The agent burned through that on a single small Python library — well before finishing investigation. Final cost for the run: ~$0.46.Why this is surprising
13 source files totaling 2800 LOC is a small target. Reading every file in full would be on the order of 30k–50k tokens. The agent should have plenty of headroom. The fact that 133k was consumed suggests one or more of:
tool_resultblock stays in the message history for the rest of the loop, so aread_fileearly in the loop continues to consume tokens on every subsequent turnparse_structureoutput — the agent calledparse_structureon all 13 files in a single turn; structured AST output may be much larger than expectedread_file("ai.py", max_bytes=8192)then laterread_file("ai.py", max_bytes=16384), doubling the content in context_DIR_SYSTEM_PROMPTplus survey injection (after #6) plus child summaries grows non-triviallyWhy this matters
If a 13-file Python library exhausts the budget, then realistic targets (hundreds of files, multi-language, deep trees) will be unusable without intervention. The current behavior — early exit with whatever was cached so far — produces an incomplete report and a confusing user experience.
Possible directions (not a decision)
[result elided]placeholderparse_structureoutput size explicitly and force the agent to use targeted queriesMAX_CONTEXTtoward the model's real limit (200k for Sonnet, 1M for Sonnet 4.6) — cheapest but does not address the root causeAcceptance
--ai luminos_libcompletes without hitting the context budgetSequencing
This issue should be triaged after Phase 2 ships (#4–#7 plus #42), before any phase that adds more tools or longer prompts (Phase 3 planning, Phase 4 external knowledge tools). Adding more capability before fixing the budget will only make this worse.
Reproduction
Look for:
Context budget reached — exiting earlyShipped in #52, merged to main. Closing manually — Forgejo's
Closeskeyword didn't auto-close this from the PR body.