| name | shed |
| description | Context window hygiene for long-running LLM agents. Decision rules for when and how to compress, mask, switch, or delegate context — backed by research (JetBrains/NeurIPS 2025, OpenHands, Letta/MemGPT, LLMLingua). Use when an agent runs for extended sessions, accumulates large tool outputs, approaches context limits, or suffers from compaction/overflow. Also use when designing agent architectures that need to manage context over time. |
Shed — Context Hygiene for Agents
Shed what you don't need. Keep what matters.
Named for molting — the process of shedding an outer layer to grow. Your context window is your skin. When it gets too heavy, shed the dead weight.
Core Principle
Tool outputs are 84% of your context growth but the lowest-value tokens you carry. (Lindenbauer et al., NeurIPS 2025 DL4C workshop, measured on SWE-agent). Everything flows from this.
The Rules
After Every Tool Call
- Extract, don't accumulate. When a tool returns large output (file contents, search results, logs, API responses), immediately write the key facts to a file or compress into bullets. The raw output is now disposable.
- Ask: "Will I need this verbatim later?" Almost never. The answer you extracted is what matters, not the 500 lines that contained it.
When Context Reaches ~70%
- Trigger condensation. Don't wait for the platform to compact you — that's losing control of your own memory. At 70%, actively shed.
- Mask old tool outputs first (free, no LLM calls). Keep your reasoning and action history intact — you need your decision chain, not the raw
ls -la from 20 turns ago.
- Summarize reasoning only as backup. If masking isn't enough, compress old reasoning turns. But this is lossy and costs an LLM call — use sparingly.
- Never re-summarize a summary. If you've already condensed once and context is growing again, switch context or spawn a sub-agent. Recursive summarization compounds errors.