nac7

tooltrim: Compress LLM Agent Tool Outputs

tooltrim trims large tool results before they enter an LLM agent’s context, using content-aware, query-aware extraction and optional retrieval of the original output. It suits teams looking to reduce context use without changing their provider or agent framework.

View on GitHub Compare
Stars
3
Forks
0
Stars, last 30 days
+0
Last commit
2 months ago
Contributors
2

Our take

Newless than six months old

Health score

33/100

How it is scored
Activity
55
Community
35
Issues
21
Pull requests
21

+0 stars in the last 30 days

  • Fewer contributors than 86% of the projects we track

tooltrim is a promising, actively developed way to address tool-result bloat, but its short history and contributor concentration call for workload-specific validation before relying on it in production.

Good fit if

  • Your Python-based agents repeatedly receive large tool outputs and can benefit from query-aware, extractive compression.
  • You want to keep the original result retrievable, or prefer a proxy or framework adapter over changing each tool’s behavior.
  • You can evaluate quality on your own tasks; the project is MIT-licensed and has recent commits and releases, with most code contributions coming from one person.

Look elsewhere if

  • You need established project history or a broadly distributed maintainer base; this is a new project with only two contributors and work concentrated in one.
  • Your agent depends on information that compression may omit and cannot use a retrieval step to recover it.
  • You need a completed, broad end-to-end task-success evaluation before adoption; the README describes the tau-bench evaluation as a pilot.
All health signals
Last commit2026-08-11 (2 months ago)
Commits, last 90 days12
Releases, last 12 months7 (latest v0.3.3, 2026-08-11)
Contributors2 (top contributor: 60% of commits)
Issues closed, last 90 days0
Pull requests merged, last 90 days0
Project age3 months

Checked on 2026-10-09 with the GitHub API.

Project history

Daily GitHub snapshots since Oct 7, 2026. History covers stars and forks; health signals are not tracked historically.

Selected snapshot

Stars

3

Forks

0

Change since Nov 9, 2026: 0 stars·0 forks

Overview

tooltrim is a Python library and proxy for compressing the results returned by agent tools, such as fetched pages, JSON responses, logs, and documents. It targets context bloat caused by replaying large tool outputs across agent turns, rather than compressing prompts or conversation history.

Its extractive approach keeps selected content and stores the original for retrieval by reference. The project also includes benchmarks for token savings and answer faithfulness, though those results are based on the project’s own test cases and should be validated against your workload.

Key Features

  • Wrap Python tools with a decorator or use the ToolCompressor API to compress string outputs.
  • Apply content-specific handling for HTML, JSON, tabular data, logs, and plain text.
  • Use a query to prioritize relevant content with BM25, or configure an embedding scorer.
  • Retrieve the original output, or a slice of it, using a reference returned with the compressed result.
  • Run an OpenAI-compatible proxy that also accepts Anthropic message formats and compresses tool results in flight.
  • Integrate with LangChain, LlamaIndex, OpenAI Agents, and MCP through optional packages.
  • Use a CLI, streaming compression, and file, Redis, or S3 stores for different deployment needs.

Use Cases

  • An agent that fetches long web pages can keep relevant passages in its context while retaining access to the full page.
  • Teams using tools that return large JSON arrays, CSV exports, or log dumps can reduce repeated context without simply truncating the output.
  • Applications that need to try output compression without modifying agent code can route compatible OpenAI or Anthropic requests through the proxy.
  • Framework users can wrap existing LangChain, LlamaIndex, OpenAI Agents, or MCP tools rather than replacing their agent setup.

What you need

Detected in the repository

  • Python >=3.9 (from pyproject.toml)
  • A Dockerfile, so it can run in a container
  • A test suite and automated checks on GitHub Actions

License in plain words

MITpermissive

  • Commercial use: yes
  • Modify and redistribute: yes
  • You must keep: the copyright and license notice
  • Share your changes: no

A summary, not legal advice: the LICENSE file is what applies.

Getting Started

Install the core package:

pip install tooltrim

See the README for examples, optional integrations, proxy setup, and benchmark details.

Considerations

The project is new, so its recent development and releases are encouraging but do not establish long-term maintenance. Most contributions come from one person, and the supplied health data shows no issues closed or pull requests merged in the last 90 days; this is limited evidence of issue-handling practices, especially for a young repository. Compression is extractive and can omit information, so test it against representative tool outputs and provide expand() access where omissions could affect agent behavior. The README reports promising single-turn faithfulness results, while its multi-step tau-bench evaluation remains under pilot; frontier-model runs and native streaming passthrough in the proxy are listed as roadmap items. The core has no runtime dependencies, but optional features may require additional packages or services such as Redis, S3, or embedding models.

Found this useful?

Share it with someone who would like tooltrim.

Comparisons