Large models repeatedly "forget" during long tasks, losing track of their initial goals, a longstanding issue in the intelligent agent industry. The root cause may not lie in the model itself, but in the "execution framework" that wraps it. A AWS self-developed cloud programming intelligent agent design guide points out the problem clearly: shallow agents encounter context overflow, get distracted and go off-topic during long cycles, and cannot maintain state. Fixing this layer is the harness, which manages everything "outside the model."
A new study reviewing multiple mainstream frameworks has lifted the veil on this layer. LangChain Deep Agents, Claude Code, Manus, OpenAI Codex, and Amazon Bedrock AgentCore each use four "engines"—context budget, compression, to-do state, and cross-session memory—to transform shallow loops into deep agents capable of handling long tasks.
The most counterintuitive point is that simply increasing the context window doesn't solve the problem. Chroma's Context Rot report evaluated 18 large models and found that even in simple retrieval tasks, the longer the input, the less reliable the model becomes. Anthropic explains that attention mechanisms generate n² pairwise relationships for n tokens, and each additional token consumes a limited "attention budget." Context is a diminishing resource, not a bucket. Manus also revealed that a typical task involves calling tools about 50 times, with an input-output ratio close to 100:1. The initial instruction gradually drifts toward the middle of the window—precisely the location where memory degradation occurs.
The first engine is context budget and offloading. Deep Agents come with two hard-coded rules: if the tool returns more than 20,000 tokens, it is written to the file system, with only the path and the first 10 lines of preview retained; when the session context exceeds 85% of the window, old edit calls are truncated into pointers. Claude Code applies the same logic before loading, automatically limiting memory to 200 lines or 25KB, with the MCP tool mode defaulting to listing names and pulling them as needed. AWS AgentCore's demonstration is even more thorough: the coordinator spawns three browser sub-agents in parallel, each operating in its own MicroVM. The analysis sub-agent only receives structured results, with an expected duration of 4 to 6 minutes, while serial execution can be up to three times slower.
The second engine is compression. When offloading isn't sufficient, the framework summarizes the conversation near the limit and restarts it. Claude Code's compression prompt retains architectural decisions and unresolved bugs, discards redundant outputs, and after compression, re-reads the last up to five modified files and re-injects the skill text. It also writes the complete original record to disk, allowing facts lost in the summary to be retrieved later. Deep Agents takes "preserving the goal" as a structural feature, with the summary document specifically dividing sessions into intent, generated products, and next steps. Compression has been pushed down to the API level: OpenAI Responses API provides server-side compression via `compact_threshold`, and Codex relies on it to handle long programming tasks. The Claude platform also offers customizable compression editing options with writeable instructions.
The third engine is to-do state and "chanting." Manus' approach is simple—create a `todo.md` and step-by-step check off items, effectively embedding the goal at the end of the context, pushing back against "being submerged in the middle." However, this is not always effective: Deep Agents changed its to-do middleware to optional in version 0.7 released in July 2026, as evaluation showed that turning it off slightly increased rewards and reduced costs. LangChain still recommends re-enabling it for long tasks, weak models, and interfaces needing progress display.
The fourth engine is cross-session memory. Claude Code re-loads CLAUDE.md and automatic memory after each compression. AgentCore Memory runs extraction strategies in the background, allowing the coordinator to recall them directly instead of re-analyzing. However, research from ETH Zurich casts cold water: context files like AGENTS.md typically do not improve success rates, yet increase reasoning costs by 20% to 23%, with each reload being a fixed tax on the attention budget. Therefore, Claude Code recommends keeping CLAUDE.md under 200 lines.
The study finally reminds us that whether a framework truly "grasps the goal" must be verified through forced compression tests—the most dangerous failure is when an agent immediately asks for clarification after a summary or incorrectly declares a task completed. In other words, keeping an agent from getting lost on a long journey isn't about how big the model is, but how finely tuned these engines are.






