context-compression
Skill8 starsChanged 3 months agoMITView on GitHub
Compress an agent's context — long environment observations and accumulated interaction history — on long-horizon tasks using Microsoft's ACON method: threshold-triggered LLM compression with guidelines optimized from contrastive failure analysis. Trigger when an agent loop's context grows across many tool-call steps and blows token budgets or degrades decisions, when designing what a summarizer/compressor must preserve, or when distilling a compressor into a smaller model.
24 other projects use a version of this.
Adopted by
Most recently taken up by
- docxology/templatetheir own version, first seen Oct 30, 2026
- viasrijan/crazy-skillstheir own version, first seen Oct 20, 2026
- AbdelrhmanAlquran/claude-skillstheir own version, first seen Oct 20, 2026
- xfstudio/skillstheir own version, first seen Oct 13, 2026
- brake71/1c-ssl-skillstheir own version, first seen Oct 13, 2026
- DBAAZzz/skillstheir own version, first seen Oct 13, 2026
Used with
Projects with it also use bdi-mental-states, hosted-agents and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
Downey6689Skillbdi-mental-states
Transforms external RDF context into BDI mental states. Invoke when modeling beliefs, desires, and intentions.
Also in 5 projects that use this
Downey6689Skillhosted-agents
Guidance for hosted/sandboxed agents. Invoke when running background agents in isolated VMs or multi-client setups.
Also in 5 projects that use this
DVwebBiz11Skillself-improvement-loops
This skill should be used when the harness, scaffold, workflow, or optimizer itself is the optimization target: recursive self-improvement (RSI) loops, meta-harnesses, self-improving harnesses that mine their own failures and propose bounded edits, evolutionary or population-based search over agent scaffolds, acceptance gates for self-modifying systems, and agentic context evolution where the mechanism that produces context is versioned and evolved. Route governance of a single autonomous loop (locked surfaces, durable logs, rollback, novelty gates, approval boundaries) to harness-engineering, measurement and quality-gate design to evaluation, judge design to advanced-evaluation, and remote sandbox infrastructure to hosted-agents.
Also in 4 projects that use this
DVwebBiz11Skilllong-horizon-prompting
This skill should be used when writing, enhancing, or evaluating the launch prompt for a long-running autonomous agent or a parallel multi-agent orchestration attacking a hard problem: pseudo-formal task briefs that define terms and an exact success predicate linguistically, enumerate non-counting outcomes, set persistence rules with explicit stop and return conditions and effort floors, manage a diverse portfolio of parallel approaches with an approach registry and blocked-route bookkeeping, and gate the return on adversarial audit. Route agent topology and coordination protocols to multi-agent-patterns, runtime control surfaces and loop governance to harness-engineering, evaluator and quality-gate construction to evaluation, judge design to advanced-evaluation, and compaction or memory mechanics to context-compression and memory-systems.
Also in 4 projects that use this
AbdelrhmanAlquranSkilllatent-briefing
This skill should be used when the user asks to "share memory between agents", "KV cache compaction for multi-agent", "orchestrator worker context", "latent briefing", "reduce worker tokens", "cross-agent memory without summarization", or discusses Attention Matching compaction, recursive language models with workers, or token explosion in hierarchical agents.
Also in 4 projects that use this
Dimks777Skillmemory-system
Развёртывание и обслуживание 3-слойной системы памяти для любого агента OpenClaw — чтобы контекст переживал сессии. Активируется на: настрой память, memory setup, проверь память, memory check, почисти память, memory cleanup, память.
Also in 5 projects that use this
- +2 more from Downey6689
Other versions24 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 24
- bojieli/ai-agent-book-projects★ 53ksame name
- bojieli/ai-agent-book★ 53ksame name
- muratcankoylan/Agent-Skills-for-Context-Engineering★ 18ksame name
- vudovn/ag-kit★ 8.2ksame name
- vudovn/antigravity-kit★ 8.2ksame name
- brake71/1c-ssl-skills★ 85same name
- Fandry96/k3-agentic-skills★ 27same name
- docxology/template★ 23same name
- soumatheusgomes/agentville★ 9same name
- xfstudio/skills★ 9same name
14 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository21 other files it gives its agents.
- agent-design-fundamentalsSkill
- agent-evalsSkill
- agent-failure-preflightSkill
- agentic-coding-disciplineSkill
- agent-improvement-loopSkill
- agent-sandboxingSkill
- coding-agent-securitySkill
- context-engineeringSkill
- gpt-56-promptingSkill
- long-running-harnessSkill
- mcp-2026-migrationSkill
- mcp-code-executionSkill
- memory-compactionSkill
- monorepo-agentsSkill
- planner-evaluator-harnessSkill
- prompt-cache-optimizationSkill
- prompt-engineering-canonSkill
- skill-authoringSkill
- spec-driven-devSkill
- tool-designSkill
- zero-trust-agentsSkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 3 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 17 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
Use this skill when:
- Distinctive: line 24
Do NOT use when:
- Distinctive: line 53
Before shipping a compressor into an agent loop:
“Common” is measured: kept by at least 6 in 10 of the 17 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Context Compression for Long-Horizon Agents (ACON)
This skill distills Microsoft Research's ACON (Agent Context Optimization) framework into an operating procedure for compressing agent context on long-horizon tasks. Applied correctly, this class of compression cut peak token usage by 26-54% across AppWorld, OfficeBench, and Multi-objective QA while largely preserving task success, and lifted smaller-LM agents by up to 46% by removing context distraction. Applied naively, it destroys performance: on AppWorld, a generic "summarize this" compressor scored 43.5% task accuracy where an optimized-guideline compressor scored 56.5% (no-compression baseline: 56.0%).
When to use
Use this skill when:
- An agent loop accumulates long histories of actions and observations across many steps (tool outputs, API responses, file dumps) and context growth is raising cost or degrading decisions.
- Tool/environment observations are verbose and noisy (raw API payloads, scraped pages, logs) — the highest-value compression target.
- You are running a smaller LM as the agent. Compression helps small models most: in ACON's experiments, compressed context improved smaller-LM agents by 32% (relative) on AppWorld and 46% on Multi-objective QA, because "excessively long contexts dilute relevant information, distracting the model with outdated or extraneous details" (ACON paper).
- You need to write or tune the prompt/guideline for a summarizer that sits inside an agent loop.
Do NOT use when:
- The task is single-step or short-horizon — context never approaches the trigger thresholds, and the compressor call is pure overhead.
- The task is information-dense and every fine-grained detail may be load-bearing. ACON's own results show a real accuracy tax on such tasks: OfficeBench dropped from 76.84% to 72.63% under aggressive (utility + compression-maximized) compression, and Multi-objective QA exact match fell from 0.366 to 0.336 even as peak tokens fell 54.5%. If accuracy is sacrosanct and budget allows, keep full context.
Rules
- Compress two things separately: observations and history. ACON defines distinct compressors for (a) each environment observation as it arrives and (b) the accumulated interaction history. They have different guidelines and different triggers. Do not use one generic summarizer for both.
- Trigger compression by threshold, never unconditionally. Apply observation compression only when the observation length exceeds a threshold T_obs; apply history compression only when history length exceeds T_hist. ACON's experiments used T_obs = 1024 tokens and T_hist = 4096 tokens, and ablations found these moderate values give the best trade-off — accuracy close to no-compression while still cutting peak tokens substantially. Smaller thresholds compress more often and degrade accuracy; larger thresholds preserve accuracy but cost more.
- Compress with an LLM following an explicit natural-language guideline, not with heuristics. The guideline tells the compressor what to keep and what to drop. ACON's guideline-driven compressor beat FIFO (keep the most recent k interactions), embedding-based retrieval, LLMLingua, and naive summarization prompting on task success. The naive-prompt gap alone was 43.5% vs 56.5% on AppWorld — the guideline is where the performance lives.
- Optimize the guideline from contrastive failures, not from intuition. The ACON loop: run tasks with full context and with compressed context; collect the pairs where the agent succeeds with full context but fails with compressed context; have a capable LLM (ACON used OpenAI o3 as the optimizer) analyze each failure to identify what information the compression destroyed; update the guideline from that feedback. Generate multiple candidate guidelines, evaluate each on the contrastive task set, and keep the best performer. This is optimization in natural-language space — no fine-tuning, works with proprietary agent models.
- Run utility maximization first; treat compression maximization as an optional second pass. ACON's two stages: the utility step (ut) fixes information loss using success/failure pairs — it is the safer step. The compression step (co) then conditions on tasks that succeeded with compressed context and asks which information was actually used during execution, pushing toward shorter outputs. The co step can slightly hurt accuracy depending on the environment (it helped on AppWorld's noisy API outputs: 51.2% ut-only vs 56.5% ut+co; it cost accuracy on OfficeBench). If your task punishes lost detail, stop after ut.
- Budget the optimization, not just the inference. Guideline optimization itself cost under $2 per benchmark with o3; the dominant cost is collecting trajectory rollouts (roughly $20 for the AppWorld training set). A one-time spend of tens of dollars is the price of a compressor that does not silently break the agent.
- Distill the optimized compressor into a small model to kill runtime overhead. ACON distilled the gpt-4.1 compressor (with its optimized guideline) into Qwen3-14B, Qwen3-8B, and Phi-4 via LoRA fine-tuning with cross-entropy loss on teacher input-output pairs — (h_t, h't) for history, ((h{t-1}, o_t), o'_t) for observations — using only trajectories where the teacher agent succeeded with compressed context. Distilled compressors retained over 95% of the gpt-4.1 compressor's performance. Distill only after the guideline is optimized; you are freezing the guideline's behavior into weights.
- Judge compression by end-task success, never by compression ratio or summary quality. The only valid metric is: does the agent still complete the task with the compressed context? ACON's entire optimization signal is task success/failure on paired trajectories. A fluent summary that drops one API response ID is a failed compression.
- Expect asymmetric payoff by environment. Verbose, redundant environments (AppWorld-style noisy API outputs) compress nearly for free — ACON matched or beat the no-compression baseline there (56.0% → 56.5%) while cutting peak tokens over 25%. Detail-dense environments (OfficeBench ~38% token cut, Multi-objective QA 54.5% cut) trade a few accuracy points for the savings. Decide per-environment whether that trade is acceptable.
- If the agent model is small, compress even when budget is not the concern. For smaller LMs, compression is a performance intervention, not just a cost one — mitigating context distraction improved smaller-LM agents up to 46% (Multi-objective QA). For large frontier agents, compression is primarily a cost/efficiency intervention with roughly neutral-to-slightly-negative accuracy impact.
Checklist
Before shipping a compressor into an agent loop:
- Observations and history are compressed by separate compressors with separate guidelines.
- Compression is threshold-gated: only observations > T_obs (start: 1024 tokens) and history > T_hist (start: 4096 tokens) are compressed.
- The compressor is an LLM following an explicit written guideline — not FIFO truncation, not embedding retrieval, not a bare "summarize" prompt.
- You collected contrastive pairs: tasks that succeed with full context but fail with compressed context.
- A strong optimizer model analyzed those failures and rewrote the guideline; multiple candidate guidelines were generated and scored on the contrastive set; the best was kept.
- Utility-maximization (ut) pass done first; compression-maximization (co) pass added only after verifying it does not cost accuracy in your environment.
- Evaluation metric is end-to-end task success with compression vs without — not compression ratio, not summary fluency.
- Peak-token reduction measured (expect 26-54% range depending on environment verbosity).
- If runtime compressor cost matters: distilled into a small model (LoRA on teacher pairs from teacher-success trajectories only) and verified ≥95% of teacher compressor performance retained.
- For detail-critical tasks: explicitly signed off on the measured accuracy delta (ACON saw ~4 points on OfficeBench) or reverted to ut-only / no compression.
Anti-patterns
- Compressing everything, every step. Unconditional compression adds compressor-call overhead and degrades accuracy. Gate by length thresholds; moderate thresholds (1024 obs / 4096 hist) beat aggressive ones in ablation.
- Naive summarization prompts. A generic instruction cost 13 accuracy points vs an optimized guideline on AppWorld (43.5% vs 56.5%). The guideline content is the product; invest in it.
- Heuristic truncation as a substitute. FIFO recency windows, embedding retrieval, and LLMLingua-style extractive compression all underperformed guideline-optimized LLM compression on task success in ACON's comparisons.
- Optimizing the guideline by intuition. Guessing what to preserve misses the actual failure causes. Only contrastive success/failure trajectory analysis reveals which dropped information broke the agent.
- Maximizing compression ratio. The co step exists, but the paper is explicit that it can hurt accuracy depending on the environment. Never chase token savings past the point where the contrastive set shows failures.
- Distilling before optimizing. Distillation freezes the teacher's behavior. Distill only the optimized compressor, and train only on trajectories where the teacher succeeded with compressed context.
- Declaring victory on token counts. Peak-token reduction without an end-task accuracy comparison is meaningless; ACON reports both, always, per benchmark.
Source
- ACON: Optimizing Context Compression for Long-horizon LLM Agents (Microsoft Research; Kang, Chen, Han, Inan, Wutschitz, Chen, Sim, Rajmohan; ICML 2026) — https://www.microsoft.com/en-us/research/publication/acon-optimizing-context-compression-for-long-horizon-llm-agents/ — 2026-06
- Full paper (arXiv 2510.00615) — https://arxiv.org/abs/2510.00615 — v3, 2026-06 (first posted 2025-10)
Distilled from the official document(s) above on 2026-08-12. If this skill and the source disagree, trust the source.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

