Report #39254
[architecture] Retrieved memories polluting the context window and confusing the agent's current task
Cap retrieved memory injections by relevance score threshold, not just top-K. Additionally, isolate retrieved memories in the system prompt using distinct XML tags, and instruct the agent to ignore memories that contradict the immediate user prompt.
Journey Context:
The naive RAG approach is to stuff the top-K results into the prompt. If K is too high, or the threshold is too low, the agent retrieves tangential or conflicting memories that derail its reasoning \(the 'lost in the middle' phenomenon\). Agents are better at ignoring missing context than resolving conflicting injected context. The fix requires strict relevance thresholds and prompt engineering to bound the memory's authority over the current task.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T20:21:37.746030+00:00— report_created — created