slm-compress

Featured

Compress large text, tool output, or transcripts to reduce context-window usage while keeping the full 1M window intact — call slm_compress(content, mode, reversible, ttl_seconds) to shrink content; if the result is lossy a ccr_id is returned so you can call slm_retrieve(ccr_id) later to recover the exact original; always fail-open (ok:false → continue with the original).

AI & Automation 224 stars 35 forks Updated 1 weeks ago AGPL-3.0

Install

View on GitHub

Quality Score: 87/100

Stars 20%
78
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# slm-compress — Reversible Context Compression (Surface B) ## Purpose When a tool output, transcript, or accumulated context grows large enough to crowd out working space, `slm_compress` reduces it in-place. The compressed form is used for the remainder of the session; the exact original is recoverable on demand via `slm_retrieve`. This works without a proxy and without touching `ANTHROPIC_BASE_URL`, so the full 1M context window is never sacrificed. ## Primary MCP Tool: slm_compress ``` slm_compress( content: str, # required — text to compress (max 1 MB) mode: str = "auto", # "normalize" | "auto" | "aggressive" reversible: bool = True, # store original in CCR for later retrieval ttl_seconds: int = 86400, # CCR lifetime in seconds (default 24 h) ) -> dict ``` ### Return dict (all keys always present) | Key | Type | Meaning | |-----|------|---------| | `ok` | bool | `True` on success; `False` on internal error or empty input | | `compressed` | str | Compressed text (or original on failure) | | `strategy` | str | Which strategy was applied (e.g. `"normalize"`, `"none"`) | | `tokens_before` | int | Word-count estimate of the input | | `tokens_after` | int | Word-count estimate of the output | | `ratio` | float | `tokens_after / tokens_before` (lower = more compact) | | `lossy` | bool | Whether information was removed | | `ccr_id` | str \| None | UUID4 session token; present only when `lossy=True` and `reversible=True` | | `note`...

Details

Author
qualixar
Repository
qualixar/superlocalmemory
Created
7 months ago
Last Updated
1 weeks ago
Language
Python
License
AGPL-3.0

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Featured

slm-status

Health and optimization stats for SuperLocalMemory — call slm_optimize_stats() for live compression and cache counters (compress_runs, tokens_saved_compress, cache_proxy_hits, cache_proxy_misses, cache_kv_hits, cache_kv_misses); run slm status [--json] for system state (mode, profile, DB size, fact/entity/edge counts) and slm doctor [--json] for preflight including the "Optimize (Surface B)" health line; use together to confirm optimization is actually saving tokens.

224 Updated 1 weeks ago
qualixar
AI & Automation Listed

compress-context

Compress a given file (CLAUDE.md, skill file, prompt file) into token-efficient symbolic notation. Rewrites the file in-place and maintains a symbols.md legend. Use when asked to compress, reduce tokens, shorten prompts, or make context more efficient.

0 Updated 2 weeks ago
rs2pydev
AI & Automation Listed

semantic-compress

Make an LLM-directed document smaller while preserving what it does. Two modes: a local span-level core->pointer pass, and an A/B-validated distill loop that produces the smallest document that behaves the same as the original. Point at core knowledge the model already holds (a concept name activates it); keep project-specific detail explicit and verbatim. TRIGGER when asked to compress, tighten, shorten, or strip a prompt / instruction / system message meant for an LLM; to distill a skill; to compress a whole document; to make this smaller while preserving behaviour; to A/B test a compression or produce a behaviourally-equivalent compression; when an instruction set explains concepts the model already knows from training; or when reducing token cost of an LLM-directed prompt without losing meaning. Not for human-facing prose - that is /deslop.

30 Updated today
bjcoombs