« All posts

Toolgz cuts LLM tool-definition tokens by ~80% without accuracy loss

Toolgz reduces LLM tool-definition token usage by ~80% while preserving accuracy, validated across 420 runs on four frontier models.

Toolgz is a zero-dependency library that compresses MCP/SDK tool schemas before they hit the model, reclaiming roughly 80% of the tokens normally spent on tool definitions. A 420-run cross-provider benchmark across four frontier models (Claude Opus, Grok, Gemini, GPT) showed prompt tokens falling 71-85%, task success holding at 15/15, and latency improving on every provider tested.

The library was stress-tested against deliberately confusable tool sets (search_issues vs list_issues, approve vs merge) to confirm accuracy doesn't degrade — the model converts a recall problem into a retrieval problem instead of losing selection ability. An early round showed OpenAI costs rising 15% despite a 69% context drop; tracing rejected calls uncovered three argument-mapping bugs (models substituting q for query, calling map codes as tool names, flattening nested arguments). Fixing them flipped OpenAI's number to -7% and drove malformed arguments to zero across all providers.

toolgz exposes recommendLevel() to pick between level 1 (free, near-zero downside) and level 3 (dispatcher + lookup tool, the source of the 80% figure), and validates every call against your original schema before dispatch. It's explicitly not yet measured at level 3 on non-frontier models — argument errors rose on Haiku 4.5 — and offers limited benefit on small tool sets under ~15 tools.

This synthesis was produced from its source by AI; there is no human editor or manual review step. How we work