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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb168ccb4317a76b7865ae56ef1fa6ea757d26c4ce3fa916682f1bb69d315837
|
|
| MD5 |
3eacc2231df4b8efaa0d3549470f3cea
|
|
| BLAKE2b-256 |
dfa8940291f011a0585f2e3faf948ed849bc4fdc7de54bd4290804e6dd9bea0c
|
Provenance
The following attestation bundles were made for context_cut-0.1.0.tar.gz:
Publisher:
publish.yml on Sunnyvk18-py/context-cut
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
context_cut-0.1.0.tar.gz -
Subject digest:
cb168ccb4317a76b7865ae56ef1fa6ea757d26c4ce3fa916682f1bb69d315837 - Sigstore transparency entry: 1939794568
- Sigstore integration time:
-
Permalink:
Sunnyvk18-py/context-cut@ffd5b8ec43fd9672dc40981a6f9ce2f60a8bd361 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Sunnyvk18-py
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ffd5b8ec43fd9672dc40981a6f9ce2f60a8bd361 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3630bde11aed6a1ff4e2636f64c93a074dcae3c3fdefa3ea41de420aa43a23e9
|
|
| MD5 |
a320be6298ea2717caaeb845d796701e
|
|
| BLAKE2b-256 |
63dcbd0d11d2cda34f051997c68d5bd3eea85d9234a9472375b03622517a95c4
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
context_cut-0.1.0-py3-none-any.whl -
Subject digest:
3630bde11aed6a1ff4e2636f64c93a074dcae3c3fdefa3ea41de420aa43a23e9 - Sigstore transparency entry: 1939794688
- Sigstore integration time:
-
Permalink:
Sunnyvk18-py/context-cut@ffd5b8ec43fd9672dc40981a6f9ce2f60a8bd361 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Sunnyvk18-py
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ffd5b8ec43fd9672dc40981a6f9ce2f60a8bd361 -
Trigger Event:
push
-
Statement type: