- In table form, field names that repeat on every record are written once as a header, and each row becomes a list of values in header order.
- Values that repeat are written once in a legend (a lookup table) and replaced by short references to it. This is the dictionary form.
- When a tool returns something similar to its previous result, terse can send only the difference between the two calls. It does so only when it can prove the difference rebuilds the full result.
- A very large field value can be offloaded: it is replaced by a handle (a short reference) that fetches the exact value on demand, so only the handle takes up context until the value is needed.
Case study · AI infrastructure · measurement
terse compresses agent tool output without losing anything, and I measured what that is worth
terse is a proxy that sits between a coding agent and its MCP servers (MCP, the Model Context Protocol, is the standard way agents call tools). It rewrites each tool result in a denser form that can always be turned back into the exact original. On its best case, nine GitHub API payloads, it uses 59% fewer tokens. A replay of my own Claude Code sessions, priced at what each API call was billed, puts it much lower: it removes 23% of what MCP results cost, which is under 1% of a session’s bill. This page explains both numbers and where the value is.
Why the best-case number shrinks in everyday use
The 59% is a fair measurement of the encoder on large, repetitive JSON. Three things stand between it and the bill.
- The model does not see everything that is sent. Some servers return each result twice, as typed data and as text. On Claude Code 2.1.218 I measured that only the typed copy reaches the model, so a saving on the text copy saves nothing. terse’s own counter now reports what the model receives alongside what crossed the wire. Over the last 30 days the two were 15.9% and 18.7%.
- Most context is billed at the cache price. Over 1,093 of my sessions in September, 96.9% of input tokens were cache reads, billed at a tenth of the normal input price. A removed token is mostly a token that would have been re-read cheaply.
- MCP results are a small part of a session. The MCP results terse handled were about 1.8% of what all my sessions cost. Shell output was 16.1% and file reads 7.1% in the October measurement, and an MCP proxy never sees either.
What a replay of my own sessions found
The replay matches every result terse changed to the session it landed in, then prices the removed tokens on each later API call that would have re-read them, at the rate that call was billed: the cache-write rate first, the cache-read rate after, the write rate again when the cache was rebuilt, and nothing after the conversation was compacted. When the model fetched a dropped value back, that fetch is charged to terse. It covers 6,309 sessions from 14 July to 4 November 2026, 720 of them with a terse result, and it joined 96.4% of the results terse changed. Sessions my test harness runs from a scratch directory are left out; a few scripted runs elsewhere are still counted.
Two tools carry the saving 92% of it
The list of credential names from my credentials broker, cut by 60.7%, and code searches with their code blocks replaced by a fetch handle, cut by 56.8%, hold 92% of the saving before fetch-backs. Fetching dropped code blocks back cost about a third of what that rule saved. The large knowledge-base lists save about 10%, and most other tools save little or nothing.
Long sessions save the most +24.1% to +6.4%
In sessions of more than 100 API calls terse removed 24.1% of MCP result cost, because a result is re-read many times; in sessions of 1 to 5 calls it removed 6.4%. A first count showed short sessions losing 15.5%. That loss came from 16 sessions of my own test harness, where a small model fetched back held-back code blocks, and the replay now leaves such sessions out. Fetch-backs did cost a lot before 26 September, about half of what holding code blocks back saved in long sessions. Since terse began keeping the first code block and stopping after the first fetch-back in a session, long sessions have fetched back once.
No sign that the model misreads it 0.1% against 2.76%
The replay cannot see whether a task succeeded, so it checks a proxy: the model calling the same tool again with the same arguments within three calls. That happened after 0.1% of the results terse changed and after 2.76% of the results it left alone. A separate test with fixed tasks, set up before it ran, found every one of 154 runs answered correctly with and without terse.
Against other compressors on the same results 23.2% lossless
On 3,184 of my own MCP results, priced the same way on 7 October, terse saved 23.2% of their cost. TOON made them 5.6% more expensive. headroom saved 45.7% in its default mode, almost all of it by removing content and leaving a marker to fetch the rest, and 0.0% in its two lossless modes.
Session-replay script: scripts/bench/replay_sessions.py in the repository, run on 4 November 2026 with no model calls. It assumes the model would have made the same calls without terse. Bill shares are API-price equivalents of a subscription.
What Claude Code now does itself
Since terse started, Claude Code has taken on part of the same job. It saves any MCP result over 25,000 tokens (by default) or 50,000 characters to a file and shows the model only the path and a preview. It loads only tool names at the start of a session and fetches a tool’s description when it is needed. It compacts long sessions and clears old tool results. The result most worth compressing is often the one Claude Code now moves out of the conversation anyway: in the replay, 72 such results saved nothing.
It also changed what terse had to get right. In a fixed-task test set up before it ran, terse was 7.8% cheaper on Haiku but 4.2% dearer on Opus 5.5, and the loss came from one task: terse’s format note sat at the top of a result Claude Code had saved to a file, filled the preview, and pushed the answer out of view. terse now treats any result over 50,000 characters as one Claude Code will save and keeps the note out of it.
Where the value is
- On a few large, repetitive results that stay in a long session. That is where I keep working: the credentials list and fewer code-block fetch-backs.
- In a guarantee: terse never trades correctness for size. A result that would not restore exactly is sent unchanged.
- In the measurement. The replay prices a change to tool output at what each later call was billed. It replaced a headline of 59% with 23% of MCP cost and under 1% of the bill, and it overturned an earlier verdict to stop the project that rested on short test tasks. It can price any tool that changes what an agent reads.
The larger costs, shell output and file reads, are outside what an MCP proxy can reach.
How it shrinks things
$ cat tool-output.json | terse gate -
round-trip lossless: PASS
cl100k tokens: 1810 -> 881 (51.3% saved)
terse leaves output that is already compact unchanged, because the saving would be tiny. A short primer, sent once per session instead of with every result, teaches the model to read the dense encoding directly, so your own code needs no decoding step. Without the primer, Haiku 4.5 answered 92% of reading questions correctly from the compressed form, against 100% from raw JSON, and the primer closed that gap. That is the one accuracy result re-run with three trials, and it held. Opus 5 scored 100% on both forms, from a single trial. The project treats the primer's effect as model-dependent: in further tests it made one smaller model less accurate. Token counts on this page use cl100k, a widely used tokenizer (the tool that splits text into the tokens that are counted).
The best case: GitHub API payloads, against TOON
This benchmark compares terse with TOON (Token-Oriented Object Notation), a published compact encoding of JSON written for model prompts, run here at version 4.1.1. Both run over the same nine GitHub API payloads (365,144 raw tokens), every row is verified lossless, and tokens are counted with the same tokenizer.
| Payload | Raw tokens | terse reduction | TOON 4.1.1 reduction |
|---|---|---|---|
| gh_workflow_runs | 76,032 | 80.4% | −7.5% |
| gh_pulls | 151,165 | 76.1% | −8.0% |
| gh_issues | 48,032 | 38.8% | −8.0% |
| gh_dir_listing | 6,736 | 31.4% | 10.4% |
| gh_commits | 69,652 | 26.5% | −4.5% |
| gh_labels | 632 | 15.2% | 19.0% |
| gh_rate_limit | 357 | 13.4% | 18.8% |
| gh_commits_flat | 10,886 | 2.4% | 1.7% |
| gh_repo_single | 1,652 | 0.0% | −3.9% |
| Weighted total | 365,144 | 59.1% | −6.5% |
Percentages are the reduction against the raw JSON; a negative number means the encoding made the
payload bigger. The total adds tokens across all nine payloads first, so larger payloads count for
more. TOON grows on nested records because it repeats the chain of field names at every level, while
terse writes a repeated nested object once: gh_pulls holds sixty copies of the same
repository object, which become one legend entry. TOON did better on the two smallest, flattest
payloads.
Re-measured on 22 September 2026 against a pinned corpus, TOON at 4.1.1.
uv run scripts/bench/benchmark.py in the repository reproduces the table.
Failure handling and safeguards
- If any compression step fails, terse forwards the original tool result unchanged.
- A difference against an earlier result is sent only when it provably rebuilds the full result. Otherwise terse sends the full form.
- The compression logic has no side effects, which makes it easy to test. Tracking of in-flight calls is capped, so a flaky server cannot make terse leak memory.
Who this is for
terse suits anyone running MCP servers, agent harnesses (the programs that run an agent's loop of model and tool calls) or other setups that repeatedly feed large tool outputs to a large language model (LLM).
# install (either one)
uv tool install terse-mcp
pipx install terse-mcp
# run an MCP server behind terse
terse proxy -- uvx some-mcp-server --flags
For questions or a use case, email [email protected] · Back to portfolio