.=*****************************+=:.
:#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%+-.
:@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#+.
:+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#@@@@@@@#+.
..-+*@@@@@#=
.-%@@@@+.
.::::::::::::::::::::::::::::::::::....=%@@#:
=#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#%+-=%@@+
:@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#*=*@#:
+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#*+*@*:
.:------------------------------------=+%#@@@@@*-+#%=:.
.-+#@@@#=:+#@@#%****++++++++++++++++++++++++++++.
.-%@@@=.:*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=
.=*****************************************+=-:. .=*@#= :=+******************************:
:#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#%+=+%@#=.
:@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@##@@@%*==============================.
.=*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#####@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%
..-=*#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*
.:-=*%#@@@#%+=::..:::::::::::::::::::::::::::
.:-------------------------------------=+*%##@@@@@@%+:
+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#*=. .-+*%##############################-
:@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#%+- .=%#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@-
=#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#%*+-. :+%##%+=----------------------------------.
.:::::::::::::::::::::::::::::::::::.. :+#@%=.
.-*#@@%-
..:-=*#@@@@%-
:+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%##@@@@@@@@%-
:@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#*-
:#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#%+:.
.=+***************************++=-:.$ pip install --upgrade llmslim $ python -c "import llmslim; print(llmslim.__version__)" 0.12.0
.=*****************************+=:.
:#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%+-.
:@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#+.
:+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#@@@@@@@#+.
..-+*@@@@@#=
.-%@@@@+.
.::::::::::::::::::::::::::::::::::....=%@@#:
=#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#%+-=%@@+
:@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#*=*@#:
+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#*+*@*:
.:------------------------------------=+%#@@@@@*-+#%=:.
.-+#@@@#=:+#@@#%****++++++++++++++++++++++++++++.
.-%@@@=.:*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=
.=*****************************************+=-:. .=*@#= :=+******************************:
:#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#%+=+%@#=.
:@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@##@@@%*==============================.
.=*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#####@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%
..-=*#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*
.:-=*%#@@@#%+=::..:::::::::::::::::::::::::::
.:-------------------------------------=+*%##@@@@@@%+:
+#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#*=. .-+*%##############################-
:@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#%+- .=%#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@-
=#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#%*+-. :+%##%+=----------------------------------.
.:::::::::::::::::::::::::::::::::::.. :+#@%=.
.-*#@@%-
..:-=*#@@@@%-
:+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%##@@@@@@@@%-
:@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#*-
:#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#%+:.
.=+***************************++=-:.$ pip install --upgrade llmslim $ python -c "import llmslim; print(llmslim.__version__)" 0.12.0
Release history
Changes with consequences.
LLMSlim releases document what shipped, what changed, and where the boundary remains.
A long history is read turn by turn
User turns form their own pool with 55% of the budget, kept whole when they fit and trimmed to their relevant sentences when they do not. Replies are cut into windows that fill the rest, near-duplicates are skipped, and each kept turn is one dated block.
Standing requests and preferences
Requests like "Always include the rollback command when I ask about a deploy" go to the top of the context, and what they ask for is fetched too. When you ask for help or a plan, the preferences you stated come back with it.
Statements that may conflict
Ask "Have I ever deployed on a Friday?" and recall shows the statements that deny it and the ones that do not side by side, in date order, above the rest of the context.
Summaries from a digest
Summary, recap and ordering questions are answered from the opening of every turn and the outline of every reply, so many more exchanges fit in the budget.
Questions in any script, and never over budget
A question in Japanese, Chinese, Russian or another script is matched on pairs of its letters, with no dictionary and no model. A turn with no space is cut between characters when only part of it fits, and recall never returns more tokens than its budget.
Same-day notes are ranked by relevance
Ten notes from one morning, asked how to run the tests and where to deploy from, came back as the last four notes of the day at a 150-token budget. Recall now ranks each note against the question, so both answering notes come back at 100, 150 and 200 tokens.
Recall stays within its budget
A selection pass was accepted up to 2% over the budget. Recall now accepts a pass only within the budget and trims what is still over, so the context never exceeds the tokens you set.
Each note keeps its own time
Notes added hours apart on the same day all showed the first note's time. Each now shows its own, and notes that share a time still show it once as a header.
Install links and manifests for more clients
One-click install links in the README for VS Code, Cursor, LM Studio, Goose and Kiro, a Hermes Agent plugin, and manifests for Codex, Copilot CLI and Gemini CLI, all pinned to 0.11.2.
Tool search stays on
With a custom base URL, Claude Code turns tool search off and sends every tool definition, about 7,100 more tokens on every request. wrap now sets ENABLE_TOOL_SEARCH=true: the first request is 19,716 tokens, against 19,712 without the proxy.
Print-mode runs keep the default permission mode
Through a proxy, claude -p starts in auto mode, where commands outside --allowedTools go to a classifier. wrap now starts print-mode runs in default mode unless you choose one. It adds nothing to interactive sessions, which were not tested; pass --permission-mode yourself if it matters.
JSON is left alone by default
An agent given a shortened JSON list of 74 open issues went back for the issue text that was cut, taking a median of 12 turns instead of 4, and the run cost about twice as much. --json (proxy) or compress_json=True (LangChain middleware) turns it back on.
A billed-cost benchmark, every run published
benchmarks/claude_code_cost: eight tasks, real Claude Code 2.1.296 on Claude Haiku 5.5, protocols written before each run. A replay of the maintainer's transcripts (32 sessions and 412 subagent runs) also shows tool output is a small part of a Claude Code bill; re-reading long context is the big part.
llmslim wrap claude
A local proxy for Claude Code. Long shell, search and web output is shortened once, keeping errors and the lines related to the command, and replayed byte for byte afterwards. File reads and edits are never touched. On Claude Haiku 5.5 with thinking, 62,334 input tokens were not sent over seven requests, and the same request without the replay was rejected.
LangChain middleware and JSON that keeps every item
LLMSlimToolOutputMiddleware does the same for LangChain create_agent and writes the short version back into the agent's state. JSON lists keep every item as one compact line, so an 80-issue list stays an 80-issue list.
Postgres store and the npm client
PostgresStore lets several servers share one memory (Supabase, Neon, RDS). The TypeScript client and Vercel AI SDK tools are on npm as llmslim.
Nothing the model has seen changes
Each shortened output is stored under its call id and text and resent exactly, so earlier turns never change. The proxy listens on localhost only and never stores your API key.
Memory without extraction
Memory.add keeps each turn verbatim, so writes cost nothing and nothing becomes a wrong extracted fact. Memory.search returns the turns that answer a question, whole and under their dates, within a token budget. It stores to SQLite or memory, and Mem0Memory keeps Mem0's method names.
MCP server, HTTP API and TypeScript client
llmslim mcp gives MCP clients remember, recall, forget and fit_context tools. llmslim serve is a JSON API with API keys and a Dockerfile. The TypeScript client adds recall_memory and remember tools for the Vercel AI SDK. Recalled memory arrives as a tool result, so prompt caches keep hitting.
Claude's preserved thinking
The gptme, Hermes Agent and Pydantic AI adapters and compress_chat_messages kept thinking blocks after changing earlier turns. On Claude 5.5 models, Anthropic rejects such requests with HTTP 400. Thinking after the first changed message is now removed, and an unfinished tool round keeps its own.
The model never picks whose memory it reads
The user and agent ids come from the server or your code, never from a tool argument, so injected text cannot read or delete another user's memory. Recalled text is labelled as data, not instructions.
Transcripts, turn by turn
Speaker-labelled lines such as "Caroline: ..." or "user: ..." are each their own unit, a turn that asks a question stays with its reply, and a date stamp shared by the block is shown once. "How long" and "how many" no longer match text like "long time no see".
Agent-history adapters
A gptme context provider, a Hermes Agent context engine and a Pydantic AI history processor fit an agent's history into a token budget locally, with no model call. Tool calls stay paired with their results.
Sarvam, Exa and Neo4j behind a usage guard
UsageGuard caps rate, requests and spend before a paid call leaves the process. Sarvam gains language tools and a document source, Exa returns web results as untrusted context, and Neo4j keeps temporal agent memory.
The provenance envelope cannot be forged
Retrieved, tool and memory text can no longer close or forge the planner's provenance envelope. Trusted content renders byte for byte as before.
LangChain compressor
LLMSlimCompressor is a BaseDocumentCompressor for ContextualCompressionRetriever. Install llmslim[langchain].
LlamaIndex postprocessor and Haystack component
LLMSlimPostprocessor is a BaseNodePostprocessor (Python 3.10+, llmslim[llamaindex]); LLMSlimDocumentCompressor is a Haystack component with run(documents, query) (llmslim[haystack]).
Same rules as the core
Retrieved text stays untrusted; documents that compress to nothing are dropped; token counts are recorded in metadata and kept out of the prompt for LlamaIndex.
Query-focused selection
Structural units are ranked with BM25, light stemming, pseudo-relevance feedback and a document prior, kept whole in their original order, then topped up sentence by sentence. compress_documents() shares one budget across documents by relevance.
Code and logs keep their lines
Failures and tracebacks come first, repeated lines collapse into a count, the tail is kept, and code keeps its skeleton plus the most relevant bodies. Compressing a 1.3k-token file dropped from about 3.5 s to 7 ms.
Optional reranker
relevance="semantic" rescores the strongest candidates with a 22M-parameter cross-encoder (the semantic extra), on CPU or GPU. Any scorer(query, texts) callable works too. Without it, LLMSlim still runs no model.
Guardrails still win
Trusted instructions and preserve_patterns survive inside large units; untrusted retrieved, tool and assistant text still cannot reach the protected tier. Query-less prose behaves exactly as in 0.7.
Most relevant evidence is kept
After the budget allocation, a deterministic guard keeps the single most relevant, non-superseded document, memory or tool result whenever it fits by dropping or compressing lower-relevance evidence.
Superseded documents go first
Items whose metadata sets superseded, superseded_by, or a past valid_until are scaled down and dropped before current evidence, with a warning in the plan.
Untrusted wording earns no value
Imperative text inside retrieved, tool or assistant content no longer raises its planning value. It is still rendered as untrusted data; there is no injection detector.
Cache plans and diagnostics
Stable-prefix fingerprints, append-only reuse estimates, cache generations, invalidation reasons, and separate network-byte and token metrics are visible in Context Inspector.
Provider request builders
Execution-free OpenAI, Anthropic, Gemini, and vLLM builders expose supported cache controls. OpenAI state continuation and Gemini cached resources require explicit host opt-in.
Reported data stays distinct
Local prefix matches are estimates until a provider reports usage. Sarvam caching remains unverified; raw KV is confined to an explicit self-hosted process adapter.
Agent Context Runtime
ContextEnvelope, ContextGraph, ContextPolicy, progressive planning, quality reporting, and bounded sessions prepare a turn without taking over the agent loop or tool execution.
Context Inspector and adapters
The Studio shows before and after context, decision reasons, graph links, and a prompt-free trace. Generic, Sarvam, OpenAI-compatible, and text-only OpenAI Agents adapters return host-owned model inputs.
Quality and budget tradeoff
Across 112 offline cases, the new runtime retained all measured required facts and tool contracts, with 67.9% budget success and 18.7% context reduction. Provider-backed answer quality remains unmeasured.
Adaptive Context Planner
Multiple-choice constrained allocation selects safe representations for trusted instructions, chat, RAG, memory, tool results, and tool schemas, then explains each decision.
Failure is explicit
Required trusted content is never silently truncated. Impossible budgets produce an infeasible plan, provider candidates fail closed, and tool selection never grants execution authority.
Optional ecosystem adapters
Official-SDK Sarvam rewriting, bounded read-only Zoho sources, and PyMongo async memory remain optional extras; the base planner stays local and provider-neutral.
MCP catalog sources
Streamable HTTP and literal-argv stdio support bounded pagination, scoped caching, contract fingerprints, and stale-plan detection.
Execution belongs to the host
The optional Agents SDK bridge requires a host callback. Full and measure-only plans retain every schema; selective exposure remains research-only.
A new home for LLMSlim
A redesigned website with light and dark themes, a Sarvam integration guide, and a note on LLMSlim's acceptance into the Sarvam Startup Program.
Stable tool-contract APIs
The released tool surface supports copied schema normalization, deterministic canonical JSON, SHA-256 fingerprints, exact contract checks, and safe catalog optimization.
Retrieval remains research-only
Lexical, dense, hybrid retrieval, selective exposure, and lazy hydration are explicit experiments. They do not authorize or execute tools, and compress() keeps its established behavior.
Schema-tax evidence stays transparent
The v0.4.0 release gate records 489 passing tests, 90.93% coverage, and 375 generated tool schemas in 18 catalogs. The compact baseline produced 0.00% lossless reduction.
Provenance-aware priority locking
ContextRole distinguishes system, developer, user, assistant, tool, RAG, and general content. Untrusted RAG, tool, and assistant text cannot become hard-locked priority from imperative wording, safety patterns, or preserve patterns.
Nonce-protected rewrite template fences
User text containing a template-fence-like delimiter remains byte-for-byte unchanged while the template uses a content-preserving nonce fence, preventing fence breakout.
Context roles and token-counter telemetry
The public Python API exports ContextRole and records token_counter_used so callers can distinguish tiktoken from the documented heuristic fallback.
Inline code and CJK sentence boundaries
Inline backtick code spans no longer create false sentence boundaries, and the CJK ideographic stops 。, !, and ? are recognized by the sentence-splitting paths.
Pipelines preserve provenance
Document compression defaults retrieved context to RAG, while chat compression propagates supplied system, developer, user, assistant, and tool roles instead of flattening them.
Benchmark collection reports real pytest results
The release runner collects actual pass/fail reports rather than replaying stale tuples. The checked-in release record reports 432 passing tests, zero failures, 92.57% branch coverage, and Ruff passing.
Rewrite and hybrid strategies
compress() gained extractive, rewrite, and hybrid strategies. Rewrite-capable paths require a caller-supplied provider; the default extractive path remains offline and deterministic.
Provider and validation contracts
BaseRewriteProvider, CallableProvider, RewriteRequest, RewriteMetadata, versioned templates, and structural, instruction, entity, and similarity validation were added as public building blocks.
Rewrite work moved into a focused sub-package
Prompt construction, execution, and validation were separated into llmslim.rewrite modules, with strategy benchmarking and a CLI strategy flag added alongside them.
Instruction and entity retention
The release added explicit instruction prioritization plus regex and heuristic preservation for names, dates, financial metrics, technical identifiers, and URLs.
Chunking, embeddings, and cost tooling
It introduced semantic and hybrid chunking, optional sentence-transformers support, model cost estimation, an interactive/file-based CLI, and comprehensive benchmark tooling.
Richer ranking and result telemetry
TF-IDF plus PageRank-style sentence centrality, optional tiktoken accounting, and a standardized CompressionResult with detailed telemetry became part of the release.
Installable LLMSlim package
v0.1.0 published the llmslim package for Python 3.8+ with the public compress(), ContextCompressor, CompressionResult, token, pipeline, and cost utility exports.
Offline prompt compression foundation
The initial engine provided ratio-driven prompt compression using TF-IDF sentence scoring and thresholding, with optional semantic, fast-token, and NLTK extras.