Strategies for long-running sessions exceeding context windows.
Core Insight
Optimize tokens-per-task (total to completion), not tokens-per-request.
Aggressive compression causing re-fetching costs more than better retention.
Compression Methods
Method
Compression
Quality
Best For
Anchored Iterative
98.6%
3.70/5
Best balance
Regenerative Full
98.7%
3.44/5
Readability
Opaque
99.3%
3.35/5
Max compression
Anchored Iterative Summary Template
## Session Intent
Original goal: [preserved]
## Files Modified
- file.py: Changes made
## Decisions Made
- Key decisions with rationale
## Current State
Progress summary
## Next Steps
1. Next action items
On compression: Merge new content into existing sections, don't regenerate.
Compression Triggers
Strategy
Trigger
Use Case
Fixed threshold
70-80% utilization
General purpose
Sliding window
Keep last N turns + summary
Conversations
Task-boundary
At logical completion
Multi-step workflows
Artifact Trail Problem
Weakest dimension (2.2-2.5/5.0). Coding agents need explicit tracking of:
Files created/modified/read
Function/variable names, error messages
Solution: Dedicated artifact section in summary.
Probe-Based Evaluation
Probe Type
Tests
Example
Recall
Factual retention
"What was the error?"
Artifact
File tracking
"Which files modified?"
Continuation
Task planning
"What next?"
Decision
Reasoning chains
"Why chose X?"
Six Evaluation Dimensions
Accuracy - Technical correctness
Context Awareness - Conversation state
Artifact Trail - File tracking (universally weak)
Completeness - Coverage depth
Continuity - Work continuation
Instruction Following - Constraints
Guidelines
Use anchored iterative for best quality/compression
Run npx skillmds@latest add tools-only/197-context-compression-17a27c30 in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Context Compression It is listed under Web & Frontend on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
tools-only (@tools-only) published this skill. Their other Agent Skills are listed on their SkillMD profile.