← ClaudeAtlas

managing-agent-contextlisted

Manages context windows in long-running AI agent loops — deciding when to summarize vs. truncate, implementing rolling window patterns, preserving critical context while shedding stale state, and budgeting tokens across multi-turn agent interactions. Use when an agent is running out of context, building autonomous loops that run many turns, experiencing context window errors, trying to keep agents focused across long sessions, managing token costs in multi-turn interactions, or designing agents that need to maintain state across hours or days. Also triggers on: context limit, token limit, context window full, agent loses track, agent forgets, long-running agent, context overflow, too many tokens, context management, rolling summary, compaction, context pruning.
Krosebrook/loxihart-skills · ★ 0 · AI & Automation · score 73
Install: claude install-skill Krosebrook/loxihart-skills
# Agent Context Window Management The context window is the agent's working memory. When it fills up, the agent loses access to its own history. This skill covers architectural patterns for managing that constraint in production agent loops. Distinct from `ecc:strategic-compact` which handles Claude Code session compaction for interactive developer sessions. This skill covers autonomous agent loops that accumulate context across hundreds of tool calls. --- ## The Core Problem Every turn of an agent loop adds tokens: - The original task and system prompt (fixed) - Each user message and assistant response (growing) - Each tool call and tool result (growing fast) - Accumulated reasoning and intermediate state (growing) At some point: context limit reached → agent fails or must be restarted. Solution: proactive context management before the limit is hit. --- ## Decision Tree ``` What's your situation? │ ├─ Agent is hitting context limits in production │ → Section 1: Emergency Reduction Patterns │ ├─ Designing a new multi-turn agent │ → Section 2: Context Budget Planning │ ├─ Building an autonomous loop (many tool calls) │ → Section 3: Rolling Window Architecture │ └─ Agent loses important context mid-session → Section 4: Critical Context Preservation ``` --- ## Section 1: Emergency Reduction Patterns If an agent is hitting context limits in production now: **Option A: Truncate oldest messages (fastest fix)** Drop the oldest user/