context-compression

Implements structured summarization and probe-based evaluation for compressing long agent conversation histories.

Updated Mar 26, 2026
One-click install
npx skills add https://github.com/LGJ-Jonathan/Jonathan_Global_Claude_Skills --skill context-compression-lgj-jonathan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: context-compression
Source: https://github.com/LGJ-Jonathan/Jonathan_Global_Claude_Skills/tree/main/context-engineering/skills/context-compression
Command: npx skills add https://github.com/LGJ-Jonathan/Jonathan_Global_Claude_Skills --skill context-compression-lgj-jonathan

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Long-running agent sessions generate millions of tokens of conversation history that exceed context window limits, and naive compression loses critical details like file paths, error messages, and decision rationale, forcing costly re-exploration. ## Core Features & Use Cases - Anchored Iterative Summarization: Maintains persistent structured summaries with explicit sections for session intent, file modifications, decisions, and next steps, merging new content incrementally instead of regenerating from scratch. - Probe-Based Evaluation: Generates recall, artifact, continuation, and decision probes from conversation history, then scores responses across six dimensions (accuracy, context awareness, artifact trail, completeness, continuity, instruction following) using an LLM judge rubric. - Compression Method Selection: Provides calibrated guidance on anchored iterative, opaque, and regenerative compression approaches with benchmarked compression ratios and quality scores. - Use Case: A coding agent debugging a 401 authentication error across 178 messages hits the context limit; the skill compresses the history into a structured summary preserving the root cause, modified files, and failing tests, then validates quality with probes before discarding the original history. ## Quick Start Ask the agent to compress the current conversation history into a structured summary and evaluate whether critical file modifications and decisions survived compression.

Frequently Asked Questions about context-compression

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I compress conversation history for long-running AI agents?

Use anchored iterative summarization: define explicit summary sections for session intent, files modified, decisions, and next steps, then merge only newly truncated content into the existing summary at each compression trigger. This prevents the cumulative detail loss caused by regenerating summaries from scratch.

How do I evaluate context compression quality?

Use probe-based evaluation instead of metrics like ROUGE. Generate recall, artifact, continuation, and decision probes from the original history, collect model responses using the compressed context, and score them across six dimensions including accuracy and artifact trail with an LLM judge.

When should I trigger context compression in an agent session?

Default to a sliding window trigger at 70-80% context utilization for coding agents, which balances predictability and quality. Use task-boundary triggers when sessions have clear phase transitions such as research, implementation, and testing phases.

Why does my agent forget which files it modified after compression?

Artifact trail is the weakest dimension across all compression methods, scoring only 2.2-2.5 out of 5.0 in benchmarks. General summarization cannot reliably track files, so implement a separate artifact index or explicit file-state tracking in the agent scaffolding rather than relying on the summarizer.

What should never be compressed in agent context?

Never compress tool definitions, function call schemas, or API specs, since summarizing parameter names or types destroys the agent's ability to invoke tools. Also protect early conversation turns containing task constraints, and preserve code blocks and identifiers verbatim while compressing prose aggressively.