An agent, in its simplest form, is an LLM calling tools in a loop. That loop works for short jobs. Give it a task that runs for an hour and 200 tool calls, and it breaks in two predictable ways. The AWS Samples design guide for autonomous cloud coding agents names them directly: shallow agents suffer from context overflow, get distracted (goal loss), and do not maintain state over long periods. The layer that fixes this is not the model. It is the harness, which AWS describes as managing everything but the model.
This article opens up that layer. Compaction, memory strategy, context budgeting, and todo-state are the machinery that turns a shallow loop into a deep agent. We look at how LangChain Deep Agents, Claude Code, Manus, OpenAI Codex, and Amazon Bedrock AgentCore implement each one, with the actual thresholds they ship.
Why a bigger window does not fix it
The obvious fix is a larger context window. The evidence says it helps less than expected. Chroma's Context Rot report evaluated 18 LLMs, including 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." Context is a resource with diminishing returns, not a bucket.
For an agent loop, this is worse than it sounds. Manus reports that a typical task needs around 50 tool calls, and that the input-to-output token ratio runs near 100:1. Each observation lands in context and stays there, so the window fills with stale tool output rather than useful reasoning. The result is not a hard crash but a slow degradation: the agent loses the original goal, repeats work, or hallucinates state it no longer holds.
via MarkTechPost
