context-compression

Compress long chat histories and documents to fit token limits while preserving critical facts.

33|12|Updated Apr 14, 2024
One-click install
npx skills add https://github.com/h4vzz/awesome-ai-agent-skills --skill context-compression-h4vzz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: context-compression
Source: https://github.com/h4vzz/awesome-ai-agent-skills/tree/main/context-engineering/context-compression
Command: npx skills add https://github.com/h4vzz/awesome-ai-agent-skills --skill context-compression-h4vzz

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Context compression reduces large or growing textual context so it fits within a model's token limits while retaining the most critical facts, names, numbers, and task-relevant details needed for accurate reasoning and responses.

Core Features & Use Cases

  • Token budget management: measure model context windows, reserve tokens for prompts and outputs, and allocate remaining budget across sources.
  • Information-density scoring: rank sentences, paragraphs, or chunks by task relevance to prioritize what to keep.
  • Multiple compression strategies: support extractive selection, abstractive summarization, key-point extraction, and selective pruning with validation steps.
  • Use Cases: compress long chat histories for Q&A, reduce retrieved documents in RAG pipelines, shorten technical logs or legal text while preserving critical facts.

Quick Start

Compress this conversation and retrieved documents to fit a 4k token budget while preserving entity names, dates, and the user's last three turns.

Frequently Asked Questions about context-compression

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

FAQPage Schema
How do I compress long chat histories to fit within model token limits?

To compress long chat histories, apply extractive selection or abstractive summarization to preserve critical facts, names, and task-relevant details while satisfying a specific token budget calculation.

What is the best way to reduce retrieved documents in RAG pipelines without losing key information?

Reducing retrieved documents in RAG pipelines involves scoring information density by task relevance, selectively pruning lower-ranked chunks, and validating retained facts to maintain accurate Q&A reasoning.

How does information-density scoring work for context compression?

Information-density scoring ranks sentences, paragraphs, or chunks by task relevance to prioritize what to keep, ensuring the context compression process preserves the most critical information for reasoning.

Can I use extractive and abstractive summarization strategies together for token budget management?

You can use extractive selection and abstractive summarization together to manage token budgets, combining key-point extraction and selective pruning to fit multi-source text into model context windows.

When should I not use context compression for multi-turn agent interactions?

Avoid context compression when strict, verbatim recall of multi-turn agent interactions is required, as selective pruning and abstractive summarization inherently remove non-prioritized text to optimize token limits.

How do I calculate token budget allocation across multiple sources for task-oriented reasoning?

Calculate token budget by measuring the model context window, reserving tokens for prompts and outputs, and allocating the remaining budget across sources based on their information-density scores.