Report #14506
[architecture] Agent crashes or loses instructions when retrieved memories exceed the context window
Implement a hard token budget for retrieved memories \(e.g., max 1000 tokens\) and dynamically reduce the top\_k or increase the similarity threshold of the vector search until the retrieved payload fits the budget.
Journey Context:
A common failure mode is calculating top\_k=5 memories, which might total 3000 tokens, and crashing the prompt if the history is already long. Memory retrieval must be context-aware. The retrieval function must know the remaining context budget and adaptively truncate or filter the memory payload to fit, ensuring the system prompt and recent turns are never evicted.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T21:44:41.554181+00:00— report_created — created