Skip to main content

secondwind

Lossless, provable, composable LLM tool-output compression, in-process.

import secondwind

session = secondwind.Session()
out = session.rewrite(request)          # compress a whole request's tool outputs
print(out["stats"])                     # tokens saved
secondwind.compress(block)              # or compress a single tool-output block

# one-line LiteLLM integration:
import litellm
from secondwind.litellm import SecondwindCallback
litellm.callbacks = [SecondwindCallback()]

# ASGI gateway (Starlette / FastAPI): rewrite request bodies before you forward them upstream
from secondwind.asgi import SecondwindMiddleware
app.add_middleware(SecondwindMiddleware)

# LangChain (LCEL): compress tool outputs before the model call
from secondwind.langchain import compress_tool_outputs
chain = compress_tool_outputs() | model

# LangGraph: compress the tool outputs an agent loop re-sends before each model call
from secondwind.langchain import compress_pre_model_hook
agent = create_react_agent(model, tools, pre_model_hook=compress_pre_model_hook())

# Agno: a lossless drop-in for its LLM-based tool-result compression
from secondwind.agno import SecondwindCompressionManager
agent = Agent(model=..., compress_tool_results=True,
              compression_manager=SecondwindCompressionManager(compress_tool_results=True))

# Strands Agents: compress tool results as they are produced
from secondwind.strands import SecondwindHooks
agent = Agent(model=..., tools=[...], hooks=[SecondwindHooks()])

# Cursor: a postToolUse hook that rewrites MCP tool output the model sees
#   ~/.cursor/hooks.json -> { "version": 1, "hooks": { "postToolUse": [ { "command": "python -m secondwind.cursor" } ] } }
# Bring your own codec: it competes in the best-of-N search, and secondwind proves
# decode(encode(x)) == x for every block, so a wrong codec is dropped, never shipped.
class MyCodec:
    def encode(self, text): ...   # -> str | None
    def decode(self, wire): ...   # -> str | None
session = secondwind.Session(codec=MyCodec())     # reckless is safe: proven per-instance
session = secondwind.Session(proposers=False)     # turn the aggressive search off

# Offload big blocks and recover them on demand, or back the store with Redis / S3 / a database.
session = secondwind.Session(resolver="resolve", offload_dir="~/.secondwind/offload")
session = secondwind.Session(store=MyStore())     # any object with put(id, value) and get(id)

Every result is lossless: an inline wire is independently verifiable with secondwind.verify(wire, hash), and a large block is offloaded to a recoverable marker. The native library is bundled, so there is no build step and no model download.

Metadata

Release files for secondwind 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for secondwind 0.5.0
File
secondwind-0.5.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
secondwind-0.5.0-py3-none-manylinux_2_34_x86_64.whl Python 3 none Linux glibc 2.34+ x86-64 Details
secondwind-0.5.0-py3-none-manylinux_2_34_aarch64.whl Python 3 none Linux glibc 2.34+ ARM64 Details
secondwind-0.5.0-py3-none-macosx_11_0_x86_64.whl Python 3 none macOS 11.0+ x86-64 Details
secondwind-0.5.0-py3-none-macosx_11_0_universal2.whl Python 3 none macOS 11.0+ universal2 (ARM64, x86-64) Details

Total release size: 80.3 MB

Release files / secondwind-0.5.0-py3-none-win_amd64.whl

Download URL secondwind-0.5.0-py3-none-win_amd64.whl
Size 16.0 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
5e027532b5ad948d01735c1ce9dc8b809e474e6d632e8a6401e41c89669c5c33
BLAKE2b-256 checksum
How to use checksums
b0c5731e3b3a9ead5913a11c05654f05fd6eb94d8de55ddc1967e2c250446fe3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Release files / secondwind-0.5.0-py3-none-manylinux_2_34_x86_64.whl

Download URL secondwind-0.5.0-py3-none-manylinux_2_34_x86_64.whl
Size 16.1 MB
Tags Linux glibc 2.34+ x86-64 Python 3
SHA-256 checksum
How to use checksums
830009a77a16cfdc8b5e0fce99ceca05a08b74f844fc5555302fd5e6120f175b
BLAKE2b-256 checksum
How to use checksums
9f8cd709a33d202aed4dde906f45f51ea9c30983f0c67dc86f1e8d0a824f8cda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Release files / secondwind-0.5.0-py3-none-manylinux_2_34_aarch64.whl

Download URL secondwind-0.5.0-py3-none-manylinux_2_34_aarch64.whl
Size 16.1 MB
Tags Linux glibc 2.34+ ARM64 Python 3
SHA-256 checksum
How to use checksums
4faa9232239625887ed001f17426bc44c9d51e364cee7342941676d509192531
BLAKE2b-256 checksum
How to use checksums
4c65cfb45f16992144ed0a780d5361fbff5e16fc5ae40d9f6203314569968d38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Release files / secondwind-0.5.0-py3-none-macosx_11_0_x86_64.whl

Download URL secondwind-0.5.0-py3-none-macosx_11_0_x86_64.whl
Size 16.0 MB
Tags Python 3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
37071d54bf1e6f8aa1dbe021d21e4af5d4d7dbc2c8cc948f01627edb0495df35
BLAKE2b-256 checksum
How to use checksums
69de4e0ba76a2ce03bf5f4a63c5a7d797f7033dd274da55c9903f82550743f01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Release files / secondwind-0.5.0-py3-none-macosx_11_0_universal2.whl

Download URL secondwind-0.5.0-py3-none-macosx_11_0_universal2.whl
Size 16.1 MB
Tags Python 3 macOS 11.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
0b4583a290287ff7095d18d9ffdbb4601ecfd347171448c073cf86886cb02b1f
BLAKE2b-256 checksum
How to use checksums
a4b4c29c64d02ab1b3786a216cf6cbecc8bac6425036fb3baf7901662d0d2746
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Security for secondwind 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for secondwind-0.5.0-py3-none-win_amd64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page