Skip to main content

Agent context budget profiler and auto-optimizer for LLM pipelines

Project description

ContextCut

Your LLM agent is burning tokens. Most of them are waste. ContextCut tells you exactly where, and fixes it automatically.

The problem

Most production agents waste 40–70% of their token budget on:

  • Message history that never gets pruned
  • Tool schemas injected into every single call
  • The same context block re-sent across every node
  • RAG chunks larger than needed
  • System prompts repeated verbatim on every turn

Install

pip install context-cut

Quickstart (no API key needed)

python examples/no_api_key_example.py

Usage — one decorator

import contextcut

@contextcut.wrap(model="gpt-4o", verbose=True)
async def run_my_agent(task: str):
    result = await my_langgraph_graph.ainvoke({"messages": [...]})
    return result

await run_my_agent("Analyze Q4 sales")
report = contextcut.get_last_report()

CLI

contextcut analyze --file my_agent.py --task "Analyze Q4 sales" --export html
contextcut analyze --file my_agent.py --task "..." --auto-patch
contextcut compare --before run_abc --after run_xyz
contextcut serve

Dashboard

pip install "context-cut[dashboard]"
contextcut serve

Open http://localhost:3000

LangGraph integration

from contextcut.integrations.langgraph import LangGraphContextCutCallback

callback = LangGraphContextCutCallback(model="gpt-4o")
result = graph.invoke(task, config={"callbacks": [callback]})
report = contextcut.profile(callback.get_intercepts())

License

MIT

Project details


Download files

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

Source Distribution

context_cut-0.1.0.tar.gz (22.8 kB view details)

Uploaded Source

Built Distribution

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

context_cut-0.1.0-py3-none-any.whl (33.1 kB view details)

Uploaded Python 3

File details

Details for the file context_cut-0.1.0.tar.gz.

File metadata

  • Download URL: context_cut-0.1.0.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for context_cut-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cb168ccb4317a76b7865ae56ef1fa6ea757d26c4ce3fa916682f1bb69d315837
MD5 3eacc2231df4b8efaa0d3549470f3cea
BLAKE2b-256 dfa8940291f011a0585f2e3faf948ed849bc4fdc7de54bd4290804e6dd9bea0c

See more details on using hashes here.

Provenance

The following attestation bundles were made for context_cut-0.1.0.tar.gz:

Publisher: publish.yml on Sunnyvk18-py/context-cut

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

File details

Details for the file context_cut-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: context_cut-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 33.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for context_cut-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3630bde11aed6a1ff4e2636f64c93a074dcae3c3fdefa3ea41de420aa43a23e9
MD5 a320be6298ea2717caaeb845d796701e
BLAKE2b-256 63dcbd0d11d2cda34f051997c68d5bd3eea85d9234a9472375b03622517a95c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for context_cut-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Sunnyvk18-py/context-cut

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page