Repository navigation
Releases
v0.12.0
LLMSlim Core 0.12.0 changes how the memory engine reads a long history. When the history does not fit the budget,
Memory.search (and the llmslim mcp server's recall tool) now ranks the stored turns themselves, keeps the user's
own turns in their own share of the budget, and adds short sections for the user's standing requests, stated
preferences and statements that may conflict when the question calls for them. Summary and ordering questions are
answered from a digest of the whole history. A history that fits is returned exactly as before.
pip install --upgrade "llmslim[mcp]"Merged from 0.11.2
- The 0.11.2 fixes hold on the turn-level read path.
Memory.searchranks stored turns itself (below), so it
does not use 0.11.2'smemory/_selection.py, which is left out; the guarantees are kept as follows:- Each turn shows its own time. When the whole history fits, every turn carries its own stamp. When it is
selected from, the first kept turn of a session shows its full stamp, and a later one shows its own full stamp
when its time differs from the one shown last in its session, else the date alone. - Never over the budget. A context is at most
budgettokens (it was allowed 2% over): the fit drops the
weakest pieces until the whole fits, and anything still over is cut to the longest prefix of whole words, as in
0.11.2.history_tokenscounts the history as one text, blank lines between sessions included. - The turns of a day are ranked by relevance, as every turn already is; a one-speaker or one-session history
goes through the same selection. - A section's best line may take at most a quarter of the room (was half), so at budgets of about a hundred
tokens a request or preference no longer crowds out the turns that answer the question.
- Each turn shows its own time. When the whole history fits, every turn carries its own stamp. When it is
Changed
- Memory: a long history is read turn by turn. When the history does not fit the budget,
Memory.searchnow
ranks the stored turns themselves instead of rendered session text. When the whole history fits, the output is
unchanged.- User turns are their own pool, ranked by the same relevance as the rest (lexical, then the reranker over the
160 strongest candidates when one is set), with 55% of the budget reserved for them. A user turn is kept whole
when it fits its cap (a tenth of the budget, between 120 and 400 tokens); a longer one keeps its most relevant
sentences and is markedpartial. - Replies are cut into windows of a few sentences (about a thirty-second of the budget, 60 to 200 tokens; code
blocks and tables stay whole), ranked in a second pool, and fill the rest of the budget. - Near-duplicates are left out: a candidate whose word 5-grams are mostly in the text already kept is skipped.
- One labelled, dated block per turn:
[date] role: text. Prose stays on the label's line; code blocks and
tables follow it, fenced. Markdown headings are folded into the sentence they head, so no heading stands alone,
and a label never starts in the middle of a line. A stored line that looks like a turn label is indented, so
stored text can't pass for another turn. Kept turns are in date order, with a blank line between sessions. - Dates: the first kept turn of each session shows the full stamp (
stamp_format); a later one shows its own
full stamp when its time differs from the one shown last in its session, else the date (date_format, new,
default%Y-%m-%d). - Cuts: when a budget is too small for any whole turn, the best one is cut to fit, at a space when it has
one. A turn with no space where a whole word fits (Chinese or Japanese prose, a long URL or token) is cut between
two characters instead, never splitting what shows as one character (a letter and its accents, an emoji with its
modifiers, a flag). 0.11.2 returned such a turn's label with no text.
- User turns are their own pool, ranked by the same relevance as the rest (lexical, then the reranker over the
- Memory: questions with no Latin-script word are matched on their letters. A question written in Chinese,
Japanese, Russian or another script, or made only of common words ("What is it?"), has nothing for the lexical
ranking to match; it used to get no ranking at all (even with a reranker), so the earliest turns filled the budget.
Such a question is now matched on pairs of adjacent letters, with the same BM25; when no turn shares any, the most
recent turns come first; and a reranker or custom scorer reads the strongest of these candidates. A history check
with nothing to match gets no conflicts section. Questions with a Latin-script word or a number are ranked exactly
as before.- A standing request's words are not added to such a question: they would switch the letter matching off.
- When a user turn shares letters with the question but no reply does, the replies wait for that turn instead of
filling the budget by recency (without a reranker).
- MCP: the
recalltool's description says the stored messages come back under their dates and whole where they
fit (the most relevant parts of longer ones), as the turn-level read path returns them. - Memory: the kind of question decides the sections (fixed English patterns, no model; see
llmslim/memory/_routing.py):- a plain lookup of a past fact or a history check ("What is my salary?", "When did I say ...?", "Have I ever
...?") gets no requests or preferences section, so the budget goes to the turns that answer it (a history check
can get the section of statements that may conflict, below); - a request for help, advice or a plan gets the standing requests and the stated preferences that best match it;
- other questions get the standing requests that best match them;
- a summary, recap, ordering or "how did it develop" question is answered from the digest.
- a plain lookup of a past fact or a history check ("What is my salary?", "When did I say ...?", "Have I ever
Added
- Memory: standing requests. When a history does not fit,
Memory.searchputs the user's explicit standing
requests that best match the question (at most three) in their own section at the top ("Requests the user made
earlier:"), within 15% of the budget.- What counts: a request opens with its directive ("Always ...", "From now on ..."), asks the assistant
directly ("I'd like you to never ..."), or says when it applies ("... when I ask about X"). It is kept even when
it shares no word with the question. - What does not: a pattern word in passing ("I want to make sure my site is fast"), and assistant turns.
- Shape: each request is cut to about 100 tokens, around its directive. The matching turns are returned in
MemoryContext.requests. - What it asks for is fetched too: when the best-matching request says what an answer should include ("Always
include the number of writers when I ask about my team"), those words are added to the retrieval query. Words
that only describe a format ("step-by-step", "a table") are not. - Controls:
Memory(standing_requests=...)andsearch(standing_requests=...).
- What counts: a request opens with its directive ("Always ...", "From now on ..."), asks the assistant
- Memory: preferences. For a request for advice, a recommendation or help,
Memory.searchshows the user's
earlier statements of preference ("I prefer ...", "I'd rather ...", "I usually ...", "I don't like ...") that best
match it, in their own section after the requests ("Preferences the user stated earlier:"), at most 8 within 10% of
the budget. A long sentence is shown around the words that state the preference. The matching turns are returned
inMemoryContext.preferences.- What does not: a preference word that is only asked about ("should I prioritize ...?", "how can I
prioritize ...?"). - Controls:
Memory(preferences=...)andsearch(preferences=...).
- What does not: a preference word that is only asked about ("should I prioritize ...?", "how can I
- Memory: statements that may conflict. For a question about whether something happened ("Have I ever ...?",
"Did I ... before?", "Have I completed any ...?"),Memory.searchreads the user's statements that bear on it most
(prose only: no code, no questions on their own, no standing requests). When some of them deny it ("I have never
...", "I haven't ...", "not yet") and some do not, both kinds are shown together in date order in their own
section at the top ("Statements the user made on this that may conflict (in date order):"), at most two of each,
within 8% of the budget (the first pair may take up to a quarter of a small budget). The matching turns are
returned inMemoryContext.conflicts.- Controls:
Memory(conflicts=...)andsearch(conflicts=...).
- Controls:
- Memory: a statement is shown once per section, even when the user said it in several turns.
- Memory: overview questions. A summary, recap or ordering question ("summarize what we discussed", "in what
order did I ...", "how did my plan develop?") is answered from a digest: the opening of each user turn and each
reply, without code and without the reply's opening pleasantry ("Great question!"), plus the reply's outline (its
headings and bold list leads). Many more exchanges fit in the budget than as whole turns.- User openings get half of the digest (30% in a summary under 5,000 tokens, which keeps no reply passage
whole, so the replies' openings and outlines get more of the room), or 80% for a question about the order of
what the user brought up. - With a budget of 5,000 tokens or more, a summary also keeps the most relevant reply passages whole, in 30% of
the budget. - Controls:
Memory(coverage="auto" | "always" | "never")andsearch(coverage=...).
- User openings get half of the digest (30% in a summary under 5,000 tokens, which keeps no reply passage
llmslim.focus.ranktakes an optionalcandidates: how many of the strongest lexical candidates the reranker
reads.MemoryContext.requests,preferencesandconflicts, and the same three lists inMemoryContext.to_dict(), so
inllmslim serve'sPOST /v1/memories/searchresponse (each turn with its id, role, content, timestamps,
scoreandpartial). ...
v0.11.2
LLMSlim Core 0.11.2 fixes recall in the memory engine and the llmslim mcp server. Notes saved on the same day are now
ranked by how well they answer the question, recall never returns more tokens than its budget, and each note shows its
own time.
pip install --upgrade "llmslim[mcp]"Fixed
Memory.searchranks the turns of a session by relevance when the session does not fit the budget. Turns
without arun_idare grouped by calendar day, so a day ofremembercalls to thellmslim mcpserver is one
session. When that session did not fit,recallkept the newest turns of the day and dropped the ones that answered
the question: ten notes from one morning, asked "How do I run the tests, and where can I deploy from?", came back
as the last four notes at a 150-token budget. The same notes spread over ten days were recalled correctly.- The turns of a one-speaker session are now ranked one by one, as the turns of a two-speaker session already were.
The kept turns stay in their order, each with its time. - A history of one session (one day, or one
run_id) goes through the same selection as a history of many. It was
compressed as one text, whose[date] role: contentlines read as a log, so its newest lines won. - In both cases each kept turn is counted with the line break and
...line it can add. - A history of several sessions with two speakers each selects exactly as before.
- The turns of a one-speaker session are now ranked one by one, as the turns of a two-speaker session already were.
... [N lines omitted]counts every line of a collapsed run. When a run of near-identical lines was omitted
from its first line on, the marker counted only that run's first and last lines: a 250-line run of passing tests
showed as... [2 lines omitted]. It now counts all 250. Only the number changes; which lines are kept does not.Memory.searchshows each turn's own time. It stamped every turn of a session with the session's first turn's
time, so turns added hours apart on the same day (the normal case for thellmslim mcpmemory server, which groups
turns without arun_idby calendar day) all showed the first one's time. A session whose turns share one
timestamp renders byte for byte as before, with the stamp shown once as its header, so LongMemEval and BEAM style
contexts do not change.Memory.search(and the MCPrecalltool) no longer return more tokens than the budget. A pass of the
selection was accepted up to 2% over, and selection does not charge the...it puts between kept turns or, for
very small budgets, the session's date header. Five notes searched withbudget=120came back at 121 tokens.- A pass is now accepted only within the budget. When the last pass is still over, the context is cut to the
longest prefix of whole words that fits, which can be empty for a budget smaller than a date header. history_tokenscounts the history as one text, with the blank lines between sessions, so a history that fits
is returned whole only when it fits as joined.recallsays when no stored message fits the budget, instead of "No stored memories yet."
- A pass is now accepted only within the budget. When the last pass is still over, the context is cut to the
- A memory session with one speaker keeps one turn per line. Notes stored with the MCP
remembertool are all
userturns, and selection read a block as a transcript only with two speakers. Such a session was flattened into
one paragraph: its date was repeated on every turn and kept turns were joined with spaces. A block with one speaker
now reads as a transcript when every turn is stamped, so the date is shown once and each turn stays on its line.
Text with two speakers is selected as before.
Added
- A Hermes Agent plugin for the Hermes plugin catalog, in
plugins/hermes. It installs the existing
LLMSlimContextEnginewithhermes plugins install, pinsllmslim==0.11.1as its one Python dependency, and
declares the engine's settings so the Hermes desktop app shows them as a form. It is not part of the PyPI package. - A VS Code extension, LLMSlim Memory, in
plugins/vscode, for the VS Code Marketplace and Open VSX. It adds the
pinned MCP server (uvx --from "llmslim[mcp]==0.11.1" llmslim mcp) to VS Code's MCP support through
vscode.lm.registerMcpServerDefinitionProvider, with settings for an installedllmslimcommand and the memory
file. It is not published yet and is not part of the PyPI package.
Packaging
- The Claude Code plugin pins its MCP server to an exact version (
llmslim[mcp]==0.11.1, was>=0.11.0). The
Claude plugin directory blocks a version range as an unpinned uvx launcher. - The plugin has a README (
plugins/llmslim/README.md): what it runs, what it stores and what reaches the
network. The directory requires one. - A Gemini CLI extension manifest (
gemini-extension.jsonat the repo root) runs the same pinned server, so
gemini extensions install https://github.com/Thanatos9404/llmslimworks and the extensions gallery can index the
repo. - One-click install links in the README for VS Code, Cursor, LM Studio, Goose and Kiro.
- A Codex plugin manifest (
plugins/llmslim/.codex-plugin/plugin.json) starts the same pinned server from the
plugin's.mcp.json, for Codex and the awesome-codex-plugins list. - The plugin folder has its own LICENSE and SECURITY.md, its two skills declare a
name, and the marketplace
declares"strict": true. The HOL plugin scanner that the awesome-ai-plugins and awesome-codex-plugins lists run
checks for all of these. - The Codex plugin has an icon (
plugins/llmslim/assets/icon.png), which the awesome-codex-plugins list requires. - Agent Plugins manifests for Copilot CLI (
plugins/llmslim/plugin.jsonandmcp.json, schema 1.0.0) start the
same pinned server. Copilot CLI already read the Claude layout; the awesome-copilot list checks only these files. - Security and conduct reports go to support@llmslim.app.
SECURITY.mdandCODE_OF_CONDUCT.mdgave a GitHub
noreply address, which receives no mail.
Documentation
- Corrected figures from the 0.11.1 notes, found by checking every published claim against the raw runs:
- the lint task has 240 warnings, not 260;
- the JSON task's command returned 74 open issues (the fixture holds 90);
- the replay of real sessions priced Claude Opus 5.5 cache reads at 0.1x input; Opus 5.5 reads at 0.05x. At the
right rates cache reads are 60.9% of that bill, not 75.6%, and the compression ceiling is 13.4%, not 13.8%; - "444 real sessions" is 32 sessions plus the 412 subagent runs they started;
- pooled and test-run results now lead with the primary (default permission mode) measurement instead of a range
across two modes; - interactive sessions through the proxy were not tested for their permission mode.
- A shorter first screen in the README: what LLMSlim does in one line, setup commands for Claude Code, Codex,
Copilot CLI, Gemini CLI, Hermes Agent, Python and TypeScript, and a recorded session with llmslim 0.11.1 from PyPI
(docs/assets/llmslim-memory-demo.svg). Every earlier section is still there, below it. - Runnable examples with tests in
examples/: Claude Code memory over MCP, LangChain and Pydantic AI agents with
memory, fitting a long log into a budget, and the TypeScript client againstllmslim serve. They run offline with
fake or test models;tests/test_examples.pyand the TypeScript client CI job run them.
v0.11.1
LLMSlim Core 0.11.1 fixes three problems in llmslim wrap claude. A billed-cost benchmark of real Claude Code found
them, and this release publishes that benchmark with every run.
pip install --upgrade "llmslim[proxy]"Fixed
- Tool search stays on. With a custom base URL, Claude Code turns tool search off and sends every tool definition
on every request: about 7,100 more tokens per request in 0.11.0.wrapnow setsENABLE_TOOL_SEARCH=true.
Measured with the same prompt: 19,716 tokens with the fix, against 19,712 without the proxy. - Print-mode runs keep the default permission mode. Through a proxy,
claude -pstarts in auto mode, where
commands outside--allowedToolsgo to a classifier.wrapnow starts print-mode runs with
--permission-mode defaultunless you pass a mode or set one in your settings. It adds nothing to interactive
sessions, which were not tested; pass--permission-mode defaultyourself if it matters.
Changed
- Output that is one whole JSON document 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. Use--json(proxy) or
compress_json=True(LLMSlimToolOutputMiddleware) to turn it back on.
What the proxy does to a Claude Code bill
We counted list-price dollars from the API's usage, with cache reads and writes priced separately, on Claude Code
2.1.296 with Claude Haiku 5.5: 8 small synthetic tasks, 572 runs, protocols written before each measurement. The
primary result has both arms in Claude Code's default permission mode.
| Task | Default mode (primary) | Auto mode |
|---|---|---|
| Simulated failing CI run, about 12 KB of log | -32% | -26% |
| Lint run, 3 errors among 240 warnings | -21% | -17% |
| Test runs (1, 3 or 5 bugs) | about -4%, within noise | -2% to -15% |
| Pooled over 8 tasks, 0.11.0 compression (JSON included) | +5.3% | -5.1% |
In an offline replay of the maintainer's own transcripts (32 sessions and 412 subagent runs, almost all Opus 5.5, at
list prices), all shell, search and web output costing nothing would have cut the bill by 13.4%. Re-reading long
context was the bigger cost; Claude Code's /autocompact setting decides when it compacts.
Corrected on 18 October 2026 after a claim-by-claim audit (lint warnings, JSON issue count, Opus 5.5 cache pricing in
the replay, and leading with the primary measurement). See PR #78.
Full protocols and results: benchmarks/claude_code_cost.
Also in this release
- A Claude Code plugin marketplace:
/plugin marketplace add Thanatos9404/llmslim, then
/plugin install llmslim@llmslim. glama.json.
Known limitation
With a custom ANTHROPIC_BASE_URL, Claude Code skips a Team or Enterprise organization's server-managed settings.
Don't use the proxy where those settings must apply.
The full list is in the CHANGELOG.
v0.11.0
LLMSlim Core 0.11.0 puts Claude Code and LangChain agents on a lean context. Long test logs, build output and search results are shortened the first time the model sees them, then the same bytes are sent on every later turn, so prompt caching and Claude's thinking keep working.
pip install --upgrade "llmslim[proxy]"
llmslim wrap claudeHighlights
llmslim wrap clauderuns Claude Code through a local proxy. 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 adaptive thinking, a 10,545-token pytest log went out as 156 tokens, cache reads grew every turn, and 62,334 input tokens were not sent across seven requests. The same request without the replay was rejected with HTTP 400. Guide: docs/PROXY.md.LLMSlimToolOutputMiddlewaredoes the same for LangChain 1.xcreate_agent(pip install "llmslim[langchain-agents]").- JSON results keep every item, one compact line each. An 80-issue GitHub list went from 12,247 to 3,108 tokens with every issue listed.
PostgresStorelets several servers share one memory (pip install "llmslim[postgres]").- The TypeScript client is on npm:
npm install llmslim, with Vercel AI SDK tools inllmslim/ai-sdk.
The full list is in the CHANGELOG.
v0.10.1
LLMSlim Core 0.10.1 fixes the MCP Registry name so llmslim mcp can be listed in the official MCP Registry. There are no code changes since 0.10.0.
pip install --upgrade "llmslim[mcp]"Fixed
- The server name is now
io.github.Thanatos9404/llmsliminserver.jsonand in the README'smcp-namemarker. The registry grants namespaces with the exact GitHub login and checks the marker on PyPI, so 0.10.0's lowercase name could not be published.
Everything else is as in 0.10.0.
v0.10.0
LLMSlim Core 0.10.0 brings memory for agents with no LLM in the loop: a Python API, an MCP server, an HTTP server and a TypeScript client. It also fixes HTTP 400s on Claude models with preserved thinking for users of the agent-history adapters.
pip install --upgrade llmslim # memory, compression
pip install --upgrade "llmslim[mcp]" # llmslim mcp (Python 3.10+)
pip install --upgrade "llmslim[server]" # llmslim serveFixed: Claude's preserved thinking in the agent-history adapters
Upgrade if you use the Pydantic AI, Hermes Agent or gptme adapters, or compress_chat_messages, with Claude thinking models (#60).
- The bug:
- On Claude models with preserved thinking (Haiku 5.5, Sonnet 5.5, Opus 5.5, Fable 5.1), each thinking block's signature is bound to everything sent before it.
- The 0.9.0 adapters compressed or dropped earlier turns but sent later turns back with their thinking unchanged.
- Anthropic rejects that with HTTP 400 ("The block is bound to a different conversation") for accounts created on or after 31 August 2026. Older accounts silently lose the reasoning.
- The fix:
- After the first changed message, the adapters remove signed thinking, and they keep the thinking before it. Nothing is removed from the middle, and the result is deterministic.
- An unfinished tool round keeps its thinking, and compaction waits for the next user message unless the history can't fit otherwise.
- Every removal is logged and counted.
anthropic-betaandthinking.block_bindingare never touched.
- Live check on Claude Haiku 5.5: the second turn of a Pydantic AI agent went from a 400 to 200.
Added: memory without extraction
llmslim.memory(#56):- Writes:
Memory.addstores every turn word for word, so writes cost nothing and a turn never becomes a wrong extracted "fact". - Reads:
Memory.search(query, user_id=..., budget=...)returns the turns that answer the question, whole and under their dates, within a token budget. - Storage: SQLite or in-process.
- Coming from Mem0:
from llmslim.memory.compat import Mem0Memory as Memorykeeps Mem0 2.x's method names. - Same pipeline as the benchmarks: it reproduced the round-3 benchmark contexts byte for byte on 120 of 120 LongMemEval-S dev contexts, so those results apply. On Mem0's own LongMemEval questions, that pipeline (with its reranker) answered 78.3% for $1.04 per 1,000 questions, against 76.7% for $220.88 for Mem0.
- Writes:
llmslim mcp(#58): memory and context tools for Claude Desktop, Claude Code, Cursor and any MCP client.- The tools are
remember,recall,list_memories,forgetandfit_context. - The user is fixed by the server, never chosen by the model, so injected text can't read another user's memory.
- The tools are
llmslim serve(#59): the same memory, plus context fitting, over a small JSON API.- It uses bearer API keys, and it refuses any interface other than loopback without a key.
- Request sizes are capped.
- It comes with a
Dockerfilethat runs as non-root with a/datavolume.
- TypeScript client (#61): in
clients/typescript, not on npm yet.- It wraps every
llmslim serveroute with no dependencies. llmslim/ai-sdkgives the Vercel AI SDKrecall_memoryandremembertools, plus a middleware that saves turns.- Memory arrives as a tool result, never injected into the prompt, so prompt caches and Claude's preserved thinking stay valid.
- It wraps every
Fixed: questions match context across word forms
- "Where did I move to?" now finds "I moved to Pune". Likewise "time" and "times", "shop" and "shopping", "class" and "classes" (#57).
- Measured offline on the round-3 development splits: it's neutral within noise, and up on LoCoMo (+0.9 and +1.1 points of evidence kept). The held-out test splits weren't run for this change.
Full notes: CHANGELOG.md. Guides: memory, MCP, HTTP server, 1.0 roadmap.
v0.9.0
LLMSlim Core 0.9.0: transcripts are selected turn by turn, agent histories fit a budget in gptme, Hermes Agent and Pydantic AI, and Sarvam, Exa and Neo4j integrations run behind a usage guard.
pip install --upgrade llmslimChanged: transcripts
- Plain-text transcripts are selected turn by turn (#48). A block of speaker-prefixed lines (
Caroline: ...,user: ..., optionally after a stamp such as[8 May 2023]) is no longer joined into one paragraph and cut into sentence windows that straddle turns. Each turn is its own unit, a turn that asks a question stays with its reply, and a stamp shared by the whole block is shown once. - Transcripts keep more of the evidence a question needs (#49). A reply that asks a question back keeps its own reply too, and in "how long / how many / how much" questions the word after "how" no longer matches text such as "long time no see".
- Measured once on round 3's test split, after both changes were chosen on dev, with Claude Haiku 5.5 reading:
- LoCoMo (1,307 questions): the default mode goes from 84.4% to 87.5% at 1,000 tokens, 90.9% to 91.7% at 2,500 and 94.0% to 94.3% at 10,000.
- LongMemEval-S (180 questions): 70.6% at 2,500 tokens and 77.8% at 10,000 (official judge), 1.7 points above #48 alone.
- Dense retrieval over turns is still ahead on LongMemEval (76.1% and 80.6%). A further fix that narrowed that gap on dev did not hold up on test, so it is not in this release (#51, reverted in #52).
- Every answer, the cost per 1,000 questions and the weak spots: benchmarks/live/round3/RESULTS.md.
Added
- Agent-history adapters (#44). Each fits an agent's message history into a token budget locally, with no model call: the system prompt, tool calls and latest turns stay as they are, older tool output is compressed first, and tool calls stay paired with their results.
- gptme:
llmslim.integrations.gptme.LLMSlimContextProvider; installllmslim[gptme]. - Hermes Agent:
llmslim.integrations.hermes.LLMSlimContextEngine, selected withcontext.engine: llmslim. - Pydantic AI:
llmslim.integrations.pydantic_ai.llmslim_history_processor(max_tokens); installllmslim[pydantic-ai].
- gptme:
- Usage guard for paid integrations (
UsageGuard). It enforces a per-minute rate, a lifetime request cap and an optional unit cap. Each call reserves before it leaves the process and settles with the vendor-reported amount. - Sarvam, beyond chat (
llmslim[sarvam]):- an async provider;
- language identification, transliteration and translation;
- a PDF and image document source;
- profiles repriced to ₹15 / ₹5 / ₹60 per 1M input / cached / output tokens.
- Exa web search (
llmslim[exa]):ExaSearchSourcereturns results as untrusted RAG items with URL, date and rank, capped in USD. - Neo4j temporal agent memory (
llmslim[neo4j]):Neo4jContextStorekeeps facts with validity intervals and providessupersede(),recall(as_of=...),history()andconflicts().
Guides with runnable examples are in docs/integrations/.
Security
- Untrusted content can no longer close or forge the planner's
<llmslim_context>provenance envelope. Trusted content renders byte for byte as before. - Web-search results with unsafe URLs are dropped. The text sanitizer removes Unicode tag characters ("ASCII smuggling") and keeps ZWNJ and ZWJ.
Fixed
- Sentence centrality on large chunks. Above 4,096 sentences it no longer builds the full similarity matrix: a 24,000-sentence chunk takes about 150 MB instead of 2.3 GB. Thanks to @rlippmann (#17).
- Planner, Indic documents. A relevant one-sentence Indic document was cut mid-sentence (regression in 0.8.0). Planner results are again identical to 0.6.0 and 0.7.x on the v0.6 and v0.7 suites.
- Exa and Sarvam. Exa date and truncation fixes. Sarvam clients never follow redirects or retry inside the SDK, and they close cleanly.
Full changelog: CHANGELOG.md
v0.8.1
Patch release for LLMSlim Core: framework adapters and better PyPI metadata. Compression behaviour is unchanged from 0.8.0.
pip install --upgrade "llmslim[langchain]" # or [llamaindex] (Python 3.10+) / [haystack]Added
- LangChain:
llmslim.integrations.langchain.LLMSlimCompressor, aBaseDocumentCompressorforContextualCompressionRetriever(where you'd useLLMLinguaCompressor). Installllmslim[langchain]. - LlamaIndex:
llmslim.integrations.llama_index.LLMSlimPostprocessor, aBaseNodePostprocessor(where you'd useLongLLMLinguaPostprocessor). Installllmslim[llamaindex]; requires Python 3.10+. - Haystack:
llmslim.integrations.haystack.LLMSlimDocumentCompressor, a component withrun(documents, query). Installllmslim[haystack]. - What all three keep: document order, ids, scores and metadata. Documents that compress to nothing are dropped, and original and kept token counts are recorded in metadata.
- Options:
target_ratio(default 0.25),relevance("lexical"/"semantic"/ a callable),selection,context_role,additional_compress_kwargs. - Tested with:
- langchain-core 0.3.0 and 1.6.9
- llama-index-core 0.12.0 and 0.14.25
- haystack-ai 2.0.0, 2.21.0 and 3.3.0
Guides with runnable examples are in docs/integrations/.
Changed
- PyPI metadata:
- The summary now says what LLMSlim does.
- New keywords for prompt and context compression and the supported frameworks.
- Python 3.13,
3 :: OnlyandTyping :: Typedclassifiers.
llmslim[all]includes the three framework extras.
Benchmarks (unchanged, measured on 0.8.0): https://www.llmslim.app/benchmarks · methodology discussion: #36
Full changelog: CHANGELOG.md
LLMSlim v0.8.0: Query-focused selection and an optional reranker
Query-focused selection, an optional reranker, and line-preserving compression for code and logs.
pip install -U llmslim
pip install -U "llmslim[semantic]" # optional rerankerChanged
- Query-focused selection. With a
query,compress()no longer gives
every chunk a proportional share of the budget. It ranks the context's
structural units (documents, chat rounds with their session headers,
paragraphs, or sentence windows of long paragraphs) against the query with
BM25, light stemming, one round of pseudo-relevance feedback and a
document-level prior, keeps the best units whole in their original order,
and fills what is left with the best sentences of the next unit. Headers
such asDocument [3](Title: ...)orSession Date: ...are shown once
above any kept unit. Everything stays local and deterministic. compress_documents()with a query shares one budget (target_ratioof the
combined tokens) across documents by relevance: the most relevant documents
stay whole and irrelevant ones come back empty. Without a query it still
compresses each document on its own.- Line-structured text (code, logs, test output, diffs, listings) keeps its
line breaks: failures, tracebacks and their neighbourhood are kept first,
runs of near-identical lines collapse into one line and a count, a
contiguous tail is kept (most of the budget without a query), code keeps its
skeleton (imports and every signature) plus the full bodies of the
definitions most relevant to the query, and omitted spans are marked
... [N lines omitted]. ContextCompressor(selection=...):"auto"(default) as above,
"focus"to always use query-focused selection,"proportional"for the
0.7 behaviour.CompressionResult.selectionrecords the path used.- Compound words match in either direction ("superbowl" finds "Super Bowl",
"gall bladder" finds "gallbladder"). - Units are about 1/32 of the budget (between 40 and 220 tokens), so a
multi-passage context keeps more distinct passages.
Added
relevance="semantic"(oncompress(),compress_documents()and
ContextCompressor): an optional cross-encoder reranker,
cross-encoder/ms-marco-MiniLM-L-6-v2(22M parameters, trained on MS MARCO
only), rescoring the 80 strongest lexical candidates. It finds answers that
share few words with the question. It runs on CPU, or on a GPU when one is
available; install withpip install "llmslim[semantic]". Any callable
scorer(query, texts) -> scorescan be passed instead, for example a hosted
reranking API. The default stays"lexical": no model, no download.
Performance
- Sentence splitting looked for NLTK's punkt data on disk on every call. It
now looks once per process: query-focused compression of a 2.9k-token,
20-document context went from 213 ms to 24 ms, and of a 115k-token chat
history from 2.4 s to 0.8 s. - Guardrail detection skips text that cannot contain a protected sentence and
no longer computes entity scores it does not need. The result is unchanged
(checked on 109,424 sentence, role and floor combinations).
Fixed
- Compression never returns empty text for non-empty input: if no whole unit
fits, the best sentences or, at worst, a word-boundary prefix are kept. - Trusted guardrails and developer
preserve_patternssurvive selection even
inside units too large to keep whole (only the protected sentences are
kept). Untrusted RAG, tool and assistant text still cannot earn this tier. - A
ContextRoleenum passed ascontext_roleis recognised as system or
developer for guardrail protection (itsstr()form was compared before).
Measured (0.7.2 → 0.8.0 lexical → 0.8.0 + reranker; read by Claude Haiku 5.5)
- LongMemEval-S, 90 questions, 8,000-token budget: 25.6% → 68.9% → 76.7%
(full 114k-token history: 82.2%; on 90 fresh questions 76.7% against 72.2%). - NaturalQuestions, 20 documents, 25% budget: 62.3 → 65.7 → 75.0 (full: 86.3).
- HotpotQA distractor, 200 questions: F1 61.7 → 67.5 → 69.4 (full: 74.9).
- LongBench v1 macro at 3,000 tokens: 52.4 → 54.9 → 54.2 (full: 54.9).
- LongBench v2, 180 questions: 51.1 → 53.9 → 55.6 (full: 60.0).
- Compressing a 1.3k-token Python file: about 3.5 s → 7 ms.
- Head to head on NaturalQuestions, 300 questions at the same budget: 78.7 with the
reranker, against 78.0 for LongLLMLingua (a 7B model) and 69.0 for LLMLingua-2. - Full tables, fresh-sample reruns and head-to-head runs of LLMLingua-2 and
LongLLMLingua:benchmarks/live/README.md.
Full tables, fresh-sample reruns and the head-to-head runs are in benchmarks/live/README.md.
v0.7.2
Patch release for LLMSlim Core. pip install --upgrade llmslim
Fixed
plan_context()keeps the most relevant evidence. It no longer drops the most relevant optional document in favour of strictly lower-relevance documents that merely cost fewer tokens. After the value-maximizing knapsack, a deterministic relevance guard keeps the single most relevant, non-superseded evidence item whenever it fits by dropping or compressing lower-relevance evidence. The decision reason records when the guard applied. (#28)- Superseded documents are dropped first. Documents, memories and tool results whose metadata marks them superseded (
supersededtruthy,superseded_byset, orvalid_untilin the past) have their planning value scaled by 0.05, so they are dropped before current evidence. The plan warns for each one.ContextRuntimekeeps these keys on external source items. (#28) - Imperative wording in untrusted content no longer raises its value. This applies to RAG, tool and assistant content. Such content is still rendered as
trusted="false". There is no injection detector; seedocs/planning/ALGORITHM.mdfor known limitations. (#28) - Python 3.9 runtime sessions: creating a
RuntimeSessionoutside a running event loop no longer raises "There is no current event loop". (fd4256c)
Verification
- CI: Python 3.9–3.13 on Linux, macOS and Windows.
- The wheel was installed in a clean venv. The README quick-start output is unchanged, and the RAG reproduction keeps the current policy and drops the superseded one and the injection post.
Full changelog: CHANGELOG.md