← Dashboard

The Context Bucket

Chapter 4: What the Model Sees

800 / 8K
System prompt
Step 1

The Context Window Is a Bucket

Everything the model knows in a single turn fits in one bucket: system prompt, tool schemas, conversation history, tool results. Watch it fill up. When it overflows, things break.

Step 2

Five Layers of Context

System prompt at the bottom (always present). Tool schemas next (the model's instruction manual). Conversation history in the middle. Tool results stacking up. Working memory on top. Each layer competes for the same limited space.

Step 3

When the Bucket Overflows

Most APIs silently truncate from the beginning. Your system prompt, the agent's personality, rules, and safety instructions, gets pushed out first. The agent forgets who it is.

Context overflow is the #1 silent failure mode in production agents.

Step 4

Strategy 1: Compact Old Turns

Summarize older conversation turns into a paragraph. Keep recent turns verbatim. Click the button to see the difference: same information, fewer tokens.

Claude Code does this automatically when context exceeds 80% capacity.

Step 5

Strategy 2: Spawn Sub-agents

Instead of cramming everything into one bucket, spawn child agents with fresh context windows. Each sub-agent handles one focused task, returns a summary, and the parent stitches results together. Three small buckets beat one overflowing bucket.

Step 6

Strategy 3: External Working Memory

Manus's breakthrough: keep a todo.md file on disk. Inject it into context each turn. The agent reads its own checklist, updates progress, and never loses track, even across context resets.

The file system becomes the agent's extended memory.