pithio
Local context compression for AI agents. Less to read, details within reach.
pithio shortens the text and data your agents read from terminals, APIs, web pages and connected tools, before the model reads it. Every shortened output says what it left out, and the full original stays on your machine: when the agent needs a detail, it fetches it or queries it exactly.
Install and set up (two commands)
- Install (one line, no Rust needed):
# macOS and Linux
curl -fsSL https://raw.githubusercontent.com/allenjoseph05/pithio/main/install.sh | sh
# Windows (PowerShell)
irm https://raw.githubusercontent.com/allenjoseph05/pithio/main/install.ps1 | iex
Or with a package manager: pip install pithio or npm install -g pithio. Or download the file for your system from Releases, or build it with cargo install --git https://github.com/allenjoseph05/pithio pithio.
- Connect your agent:
pithio init --agent claude-code --write # or: codex, cursor, copilot, gemini
pithio doctor # checks the setup
That is all: from your agent's next session, its tool outputs are shortened. pithio dashboard shows what was saved; pithio uninstall --agent claude-code --write removes it again.
Results
| on real developer tool output | without pithio | with pithio |
|---|---|---|
| correct answers (171 questions, Claude Haiku) | 86.5 % | 91.8 % |
| input tokens per tool output | 39,775 | 28,330 (29 % fewer) |
| correct answers on real system logs (Loghub) | 57.4 % | 74.1 % , with 60 % fewer tokens |
| tool-result tokens on GitHub API pages | 100 % | 7.8 % , every answer still visible |
How these were measured: BENCHMARKS.md.
What it shortens
- Terminals and repositories: test runs, builds, compiler diagnostics, git log and diff, file lists.
- Tables and structured data: JSON API responses, CSV and delimited tables, YAML and TOML.
- Logs and search: application logs, failed CI jobs, code and text search matches.
- Web and MCP results: fetched web pages, issue lists, search hits, database rows, connector logs.
Source files the agent is editing and short outputs are left alone. Output is never larger than the input, and the same input always gives the same output, so prompt caches keep working.
Every output says what it did
Each shortened output opens with a note naming its level:
- Lossless: the same data, written more compactly.
- Repeats only: every distinct value or kind of line shown, repeats counted.
- Focused: some parts left out; the note says what and how to get them.
test sample::case_001 ... ok
[... 79 more lines of the kinds shown above (other numbers) ...]
test sample::reports_expired_session ... FAILED
[pithio: level 2, repeats only: every kind of line is shown, repeats folded with exact counts; original 1,204 tokens: kept locally as handle 3f2a9c1e8b7d6a54]
Getting a detail back
The agent (or you) can recover anything from a shortened output by its handle:
pithio more HANDLE # read the original, page by page
pithio more HANDLE --grep timeout # matching lines
pithio q HANDLE # the tables in it and their columns
pithio q HANDLE "count status = 500" # exact counts, sums, filters and lookups (SQL)
pithio grep HANDLE "worker 7" # lines that contain a text
Other ways to use it
- In your own Python app: pip install pithio-sdk, then client = pithio.wrap(anthropic.Anthropic()) shortens tool results in every request and adds a recovery tool. The Node SDK (@pithio/node) is coming soon.
- MCP gateway: list your MCP servers in the config, then connect your client to pithio serve --config PATH.
- Any shell command: pithio run -- COMMAND.
- Local proxy: point an Anthropic client at http://127.0.0.1:8788 (pithio proxy).
See what it saved
pithio gain # tokens saved today, this week, all time
pithio show # recent shortened outputs, each next to its original
pithio audit # checks every stored output against what its note promised
pithio dashboard # the same in a local web page
Privacy
Everything runs on your machine; pithio sends nothing anywhere. Originals are kept locally for one day (~/.pithio); pithio forget deletes them. Outputs that look like they hold a secret are never stored.
Building from source
cargo build --release -p pithio
cargo test --release -p pithio-core -p pithio
Contributing
Contributions are welcome, including first contributions. Issues labelled good first issue are scoped, explain where to look, and come with help. Comment on one to have it assigned. Start with CONTRIBUTING.md; questions go to Discussions. Security reports: SECURITY.md.
Licence
Apache License 2.0. Versions 0.1.0 and 0.1.1 were first released under FSL-1.1-ALv2; they are also available under the Apache License 2.0.