"Context management strategies:
- (1)Observation summarization — after each tool call, summarize the result to 2-3 sentences instead of keeping the full response.
- (2)Sliding window — keep the system prompt + first user message + last N messages. On current Claude models history is append-only, so the middle tool results are cleared server-side with context editing, not dropped by my code.
- (3)Context compaction — Claude's Agent SDK does this automatically: when approaching the limit, it summarizes older turns while preserving key facts.
- (4)Hierarchical delegation — offload sub-tasks to sub-agents with their own context windows. The orchestrator only sees summaries.
- (5)External scratchpad — write intermediate results to a file/DB, reference by ID instead of keeping in context."