AWS Design Guide Ties Long-Horizon Agent Failures to the Harness, Not the Model
An AWS Samples design guide for autonomous coding agents says context overflow and goal loss are harness problems rather than model problems, and details the thresholds Deep Agents, Claude Code and Bedrock AgentCore use to budget and compact context.
The guide covers four mechanisms: compaction, memory strategy, context budgeting and todo-state. It examines how LangChain Deep Agents, Claude Code, Manus, OpenAI Codex and Amazon Bedrock AgentCore implement each one, including the thresholds they ship.
A larger context window does not settle the problem. Chroma's Context Rot report evaluated 18 models, among them GPT-4.1, Claude 4, Gemini 2.5 and Qwen3, and found that performance grows increasingly unreliable as input length grows, even on simple retrieval tasks. Anthropic's context engineering guide explains the mechanism: attention creates n² pairwise relationships for n tokens, so every added token depletes a finite attention budget. Manus reports that a typical task needs around 50 tool calls and that the input-to-output token ratio runs near 100:1, which means observations accumulate while the original instruction drifts toward the middle of the window, where recall degrades.
The first mechanism, context budgeting and offloading, decides what never enters the window. Deep Agents ships two offloading rules with hard numbers. When a tool response exceeds 20,000 tokens, it is written to the filesystem and replaced with a file path plus a preview of the first 10 lines. When session context crosses 85 percent of the model's window, older write and edit tool calls, whose full file contents already live on disk, are truncated to a pointer. Only after offloading runs out of room does the harness fall back to summarization. Claude Code applies the same budgeting before the first prompt: auto memory is capped at the first 200 lines or 25KB, MCP tool schemas stay deferred by default with only tool names listed and load in full on demand through tool search, and after compaction any re-read file over 5,000 tokens comes back as a path reference rather than content.
Subagents extend budgeting to the architecture. A simulation in the Claude Code documentation has a research subagent read 6,100 tokens of files and return a 420-token result to the parent. Anthropic's guide notes that each subagent may burn tens of thousands of tokens exploring but returns a distilled summary, often 1,000 to 2,000 tokens. The AWS AgentCore walkthrough builds the same pattern: a coordinator spawns three browser subagents in parallel, each in its own MicroVM, and an analyst subagent receives only their structured findings. AWS reports a four to six minute expected runtime and says sequential processing would take up to three times longer.
When offloading is not enough, the harness compacts. Compaction takes a conversation nearing the window limit, summarizes it and restarts a new context from the summary, and it is where goal loss most often occurs, because a lossy summary can drop the one constraint that mattered. Claude Code's compaction prompt preserves architectural decisions, unresolved bugs and implementation details while discarding redundant tool outputs. Immediately afterward it re-reads up to five of the most recently modified files, reloads the rules matching those files and re-injects invoked skill bodies, capped at 5,000 tokens per skill and 25,000 in total. The documentation states that detailed instructions from early in a conversation may be lost, which is why persistent rules belong in the project-root CLAUDE.md file, re-injected from disk. Users can steer a pass with a command such as /compact focus on the auth bug fix, or move the trigger point with /autocompact.
Deep Agents turned goal preservation into a structural feature. Its summary is a structured document with dedicated fields for session intent, artifacts created and next steps, fields the LangChain team added after forced-summarization experiments showed the change improved performance. The full original transcript is also written to the filesystem, so a fact that was summarized away can be recovered later with read_file. Compaction is moving into the API layer as well.