gitmyhub

secondwind

Rust ★ 11 updated 9d ago

Losslessly compress the tool output your AI agent sends the model, prove every value survived, and report the exact tokens removed. Run it as a proxy, a library, or middleware.

A proxy and library that compresses an AI agent's tool output before it reaches the model, with proof no value was lost.

RustPythonNode.jsWebAssemblysetup: easycomplexity 3/5

Secondwind is a tool that shrinks the output an AI coding agent sends back to the language model, without losing any of the actual information, and it proves that nothing was lost. When a coding agent runs a command or reads a file, that output often gets sent back to the model as is, using up a lot of the available context space. Secondwind sits between the agent and the model, rewriting large chunks of that tool output into a more compact form while checking that every value can still be recovered before it allows the rewrite through. If a rewrite cannot be proven safe, the original output passes through unchanged instead.

You can use Secondwind in three ways. As a proxy, it runs as a standalone process that your agent talks to instead of talking directly to the model, requiring no code changes. As a library, you can call it directly from Python, Node, or a sandboxed WebAssembly build inside your own program. As middleware, it plugs into existing frameworks like LangChain, LangGraph, Agno, Strands, Cursor, and LiteLLM with a small amount of glue code.

Getting started with the command line version involves running an install script or using pip or npm for the language libraries. Two commands are enough to wire it into Claude Code: one sets up the integration, and the other runs your agent through the proxy. After a session ends, Secondwind prints a receipt showing how many blocks it compressed and how many tokens it saved, along with confirmation that every block was verified lossless.

The tool works across several API formats, including the Anthropic Messages format, OpenAI's Chat Completions and Responses formats, and AWS Bedrock's Converse format, automatically detecting which one is being used. It reports the token savings as a fact it can verify, rather than an estimate, and it is released under the Apache 2.0 license.

Where it fits