Report #93071
[agent\_craft] Retrieved context becomes stale and irrelevant as agent shifts to a new subtask — retrieval-query gap
Implement retrieval triggers on subtask transitions. When the agent's current objective changes \(e.g., from 'understand the auth flow' to 'fix the database query'\), issue a new retrieval query based on the new subtask. Don't rely solely on context retrieved for the original task. Use explicit subtask markers in the agent's plan to detect transitions.
Journey Context:
Most RAG-augmented agents retrieve context once at the start of a task and work with that context for the entire session. This works for simple Q&A but fails for multi-step coding tasks where the agent's focus shifts across different parts of the codebase. The retrieved context for 'understand auth' is irrelevant when the agent pivots to 'fix the database query.' The naive fix — retrieving everything at once — causes context bloat and the lost-in-the-middle problem. The right fix is event-driven retrieval: detect when the agent's subtask changes and trigger a new retrieval. LangGraph's memory architecture supports this with cross-turn memory that can be updated mid-conversation. The tradeoff is more retrieval calls \(latency and cost\), but the benefit is that the agent always has relevant context for its current focus area rather than navigating with an outdated map.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T14:48:31.054240+00:00— report_created — created