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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

secondwind-0.2.1-py3-none-win_amd64.whl (16.0 MB view details)

Uploaded Python 3Windows x86-64

secondwind-0.2.1-py3-none-manylinux_2_34_x86_64.whl (16.1 MB view details)

Uploaded Python 3manylinux: glibc 2.34+ x86-64

secondwind-0.2.1-py3-none-manylinux_2_34_aarch64.whl (16.1 MB view details)

Uploaded Python 3manylinux: glibc 2.34+ ARM64

secondwind-0.2.1-py3-none-macosx_11_0_x86_64.whl (16.0 MB view details)

Uploaded Python 3macOS 11.0+ x86-64

secondwind-0.2.1-py3-none-macosx_11_0_universal2.whl (16.1 MB view details)

Uploaded Python 3macOS 11.0+ universal2 (ARM64, x86-64)

File details

Details for the file secondwind-0.2.1-py3-none-win_amd64.whl.

File metadata

  • Download URL: secondwind-0.2.1-py3-none-win_amd64.whl
  • Upload date:
  • Size: 16.0 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for secondwind-0.2.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 bd54b8e48352c0e4c0ee0e4fe01e8d01d5481aa3fc27d3a12dc5528fb0a07612
MD5 b8828817b9a22c632d32c653291e5454
BLAKE2b-256 74525dff564216e5286170638d8b7dbc20c23b21ce498817a13970bb4c7b5585

See more details on using hashes here.

Provenance

The following attestation bundles were made for secondwind-0.2.1-py3-none-win_amd64.whl:

Publisher: wheels.yml on orchetron/secondwind

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file secondwind-0.2.1-py3-none-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for secondwind-0.2.1-py3-none-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f5d39f4593d2e096ef0e4dcff6970980f776799a81910dca2213c8f27f91ef26
MD5 b1532fe6b4d2aa370916a1afaeac6116
BLAKE2b-256 c18ab37b0fb1b4bc1e5930ac8611a48f002906c9d1d8dd22eae6c4bc62c9adfb

See more details on using hashes here.

Provenance

The following attestation bundles were made for secondwind-0.2.1-py3-none-manylinux_2_34_x86_64.whl:

Publisher: wheels.yml on orchetron/secondwind

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file secondwind-0.2.1-py3-none-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for secondwind-0.2.1-py3-none-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 f4fc850c477a5f26809dcbb4a14577b2f2b4eb8bfe1260a6e47c75226e81c831
MD5 4c8230fd21ecc9ca0152f49d8858a951
BLAKE2b-256 99472daac0a50de4d1192691e6302f549951c2f286a302b919d5752270dfdb4b

See more details on using hashes here.

Provenance

The following attestation bundles were made for secondwind-0.2.1-py3-none-manylinux_2_34_aarch64.whl:

Publisher: wheels.yml on orchetron/secondwind

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file secondwind-0.2.1-py3-none-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for secondwind-0.2.1-py3-none-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 1f760b38ce208259e9d3a80b9a5a2eb11a687ba1569c6ef5a069c06c0e8dfd89
MD5 5d3a65b19d0963003581adc932b1d290
BLAKE2b-256 fab25fe898efa62de9d270f82cbe3426ec6e872956e8dd22ce0229a9d2ad0ab0

See more details on using hashes here.

Provenance

The following attestation bundles were made for secondwind-0.2.1-py3-none-macosx_11_0_x86_64.whl:

Publisher: wheels.yml on orchetron/secondwind

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file secondwind-0.2.1-py3-none-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for secondwind-0.2.1-py3-none-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 54f4792694101edae0cde4f153ee82d5aa4e3df363354b552d32b0e5a19343bd
MD5 6de4733896348fdcc170b1eb0cd5534b
BLAKE2b-256 c03f3242dbe59ba70d5fc5645515a1299c012cca8fe05121ac9cbd2831f8bf62

See more details on using hashes here.

Provenance

The following attestation bundles were made for secondwind-0.2.1-py3-none-macosx_11_0_universal2.whl:

Publisher: wheels.yml on orchetron/secondwind

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.3.2

5 files

0.3.1

5 files

0.3.0

5 files

0.2.2

5 files

This release

0.2.1 This release

5 files

0.2.0

5 files

0.1.3

5 files

0.1.2

5 files

0.1.1

5 files

0.1.0

5 files

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