Works with the AI Agents you already use

    Context Compactor

    by limp

    1

    Token-saving middleware that compresses long contexts using deterministic, reversible single-token symbol mapping.

    Free

    Security scanned
    context-compactor

    context-compactor

    Example session with this skill installed

    Compress this conversation history and show me the stats for a 15-entry dictionary. I need to see the break-even point.

    • Read your context and instructions
    • Compiled the context-compactor

    I have analyzed the conversation history and applied deterministic dictionary encoding. By mapping the 15 most frequent multi-token phrases to single-token symbols, the input size was significantly reduced.

    Compression Report

    MetricValue
    Original Tokens2,840
    Compressed Body1,912
    Legend (Dictionary) Cost84
    Total Sent Tokens1,996
    Net Savings29.7%
    Break-even Turn1.2 rounds

    Encoded Context Preview

    Dictionary: §=User Interface, ¶=Authentication, ●=Database Schema, ★=Next.js
    
    The project requires a new § and updated ¶ logic. We need to refactor the ● to support ★ components.
    

    Next steps

    • Use --expand with the provided legend to verify byte-for-byte restoration.
    • Pass the dictionary to AutoCompactSession to maintain consistent mapping across multi-turn sessions.
    • Deploy scripts/auto_compactor.py as a middleware layer for your OpenAI client.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Long-context windows are expensive and slow. When your conversation history grows or you feed massive documents into an LLM, token costs balloon and prompt caching often fails. This package provides a deterministic, reversible compression layer that maps high-frequency phrases to single-token symbols, drastically reducing overhead without losing semantic data.

    What it does

    • Deterministic Compression utilizes a dictionary-based approach to replace multi-token phrases with single-token symbols.
    • Transparent Middleware intercepts chat completions to automatically compress history while keeping recent messages in raw text for reasoning accuracy.
    • Bidirectional Mapping ensures every compressed string can be expanded back to its original byte-for-byte state.
    • Hybrid Support handles mixed English n-grams and CJK (Chinese, Japanese, Korean) character strings with specialized overlap filtering.
    • Usage Analytics reports original vs. compressed token counts, saved percentages, and the break-even point for dictionary overhead.

    How it works

    1. Analyze the input text or conversation history to identify recurring phrases that provide the highest token savings.
    2. Build a mapping of these phrases to a verified pool of symbols that represent exactly one token in the cl100k_base encoding.
    3. Compress the history by replacing phrases, prefixing a small "legend" or dictionary header so the model understands the mapping.
    4. Invoke the LLM with the compacted context, significantly reducing the input payload.

    Frameworks & tools

    This tool is built for Python environments and requires tiktoken for accurate token validation. It includes a session wrapper compatible with the OpenAI Python client and any OpenAI-compatible API.

    Why this beats prompting it yourself

    Prompting an LLM to "compress this text" is lossy, non-deterministic, and consumes output tokens. This skill uses a programmatic, zero-shot algorithm that guarantees 100% data retention and precise token reduction before the LLM even sees the request.

    Use cases

    • Long-running Chatbots where conversation history grows beyond efficient window limits.
    • Technical Document Q&A containing repetitive terminology, function names, or boilerplate.
    • Token Cost Optimization for high-volume API implementations using expensive models like GPT-4o.
    • Fixed Terminology Enforcement by pre-loading standard dictionaries into the compression layer.

    Known limitations

    Requires tiktoken installed for token counting and symbol validation. Small dialogues may not see net savings due to the token cost of the dictionary header.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Free to use

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 15 days ago

    • Free with an Agensi account

    Software
    Python

    use windows,need installed tiktoken,Can be used onDeepSeek Harness (DSH),Claude Code

    Permissions

    Terminal / Shell
    Read Files
    Write Files
    Listed15 days ago

    What's inside

    Creator

    limp

    limp

    agent-skill开发

    Frequently Asked Questions

    Token-saving middleware that compresses long contexts using deterministic, reversible single-token symbol mapping.

    This skill uses the open SKILL.md standard. Use it through an MCP-compatible agent connected to Agensi, and check the compatibility information on this page for confirmed agents and required capabilities.

    Connect your AI agent to Agensi through MCP, then ask it to use context-compactor on your task. Your agent loads the latest approved version each time. Paid skills require a purchase or active subscription. Skill files are not available for download; your licence does not allow you to save, copy or export any part of a skill.

    New in Prompt & Skill Engineering

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Prompt & Skill Engineering.

    Free