Report #42724
[frontier] Agent context window fills up during long tasks causing degraded performance and lost instructions
Replace conversation history accumulation with a structured state object that gets mutated in place. Define a TypedDict or Pydantic model for your agent's working memory. Each agent step reads the current state, performs work, and returns state updates \(not messages\). Use a state reducer pattern where new values merge with or replace old values. Keep a separate bounded message log in the state for recent context, but never let it grow unbounded.
Journey Context:
The default mental model for agents is 'chat with tools' — append every message to a growing list and send it all to the LLM. This works for short interactions but catastrophically fails in production: context windows fill up, early instructions get pushed out, and costs scale linearly with conversation length. The emerging pattern is state accumulation: the agent maintains a structured state object \(working memory\) that gets updated each step, rather than an ever-growing message list. LangGraph's StateGraph is the canonical implementation. The key insight is that most information from previous steps is either irrelevant or can be compressed into a few state fields. The tradeoff is that you lose the full conversation history for the LLM to reason over, but in practice LLMs perform better with a concise structured state than with a bloated conversation history where critical information is buried. Production teams hitting context limits are converging on this independently.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T02:10:48.028053+00:00— report_created — created