Lesson 1277 of 2116
Setting Context-Window Budget Policies for Long-Running Agents
How to keep an agent's context window from filling with noise mid-run.
Lesson map
What this lesson covers
Learning path
The main moves in order
- 1The premise
- 2Summarizing Long Tool Outputs Before Returning to the Agent
- 3The premise
- 4Managing the Context Window in a Long Agent Run
Concept cluster
Terms to connect while reading
Section 1
The premise
Long-running agents drown in their own scratchpad — explicit pruning rules outperform 'just use a bigger model'.
What AI does well here
- Summarize the last N turns into a structured digest each time
- Drop tool outputs that are no longer referenced
- Pin the user goal and key constraints at the top, immune to pruning
- Track context-window utilization as a first-class metric
What AI cannot do
- Recover a fact pruned out without re-fetching its source
- Summarize losslessly — pruning is always lossy
- Decide what's important without a stated objective
Key terms in this lesson
Section 2
Summarizing Long Tool Outputs Before Returning to the Agent
Section 3
The premise
Wrap any tool that can return >N tokens with a summarizer that returns a short structured digest plus a 'fetch_full' handle.
What AI does well here
- Keep planning context small
- Preserve key entities and IDs in the digest
- Offer a way to retrieve the full output later
What AI cannot do
- Know what detail the planner will later need
- Lossless compress arbitrary content
- Replace good tool design at source
Section 4
Managing the Context Window in a Long Agent Run
Section 5
The premise
As an agent runs, context fills with noise. Without active management the model loses track of the original task.
What AI does well here
- Summarize old turns into a short rolling note.
- Drop tool outputs that have been incorporated into the plan.
What AI cannot do
- Decide what is safe to drop without your rules.
- Recover information that was summarized away.
Key terms in this lesson
End-of-lesson quiz
Check what stuck
15 questions · Score saves to your progress.
Tutor
Curious about “Setting Context-Window Budget Policies for Long-Running Agents”?
Ask anything about this lesson. I’ll answer using just what you’re reading — short, friendly, grounded.
Progress saved locally in this browser. Sign in to sync across devices.
Related lessons
Keep going
Creators · 11 min
Tool Result Truncation Strategies for Agent Loops
How to truncate large tool outputs without breaking agent reasoning.
Creators · 22 min
Provider Routing: Switch Models Without Rewriting the App
Build a small model router that can send easy, private, or expensive tasks to the right model family.
Creators · 40 min
Context Window Budgeting: What to Include, What to Cut
Long context windows tempt teams to dump everything in. Smart prompting means choosing what context actually helps — and ruthlessly cutting what doesn't.
