Report #6916
[agent\_craft] Agent retrieves context before reasoning about what it actually needs, loading semantically broad but task-irrelevant chunks
Enforce a reason-then-retrieve pattern: \(1\) the agent first articulates what specific information it needs \(which module? which layer? which function signature?\), \(2\) only then issues targeted retrieval queries, \(3\) reasons with the results. Never allow the agent's first action on a task to be a broad search — the first action should be a planning step that decomposes the information need.
Journey Context:
The default agent pattern is: receive task → immediately search codebase → reason with results. This fails because the raw task description is a terrible retrieval query. 'Fix the login bug' retrieves every file mentioning 'login' and 'bug', flooding context with test files, config files, and unrelated modules. The agent then reasons from this broad, shallow context and produces broad, shallow solutions. The fix is to insert a mandatory reasoning step before any retrieval: the agent must first identify the specific technical question \('I need to find the auth middleware function that validates JWT tokens in the API layer'\). This produces a targeted query that retrieves the one relevant function, not fifty tangentially related files. The tradeoff is one extra turn of latency and tokens, but the retrieval precision improvement is dramatic — often 5-10x fewer irrelevant chunks loaded. DSPy formalizes this as query decomposition in their RAG pipelines.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T01:19:40.747566+00:00— report_created — created