Metadata-Version: 2.4
Name: context-cut
Version: 0.1.0
Summary: Agent context budget profiler and auto-optimizer for LLM pipelines
Author: ContextCut Contributors
License: MIT
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: tiktoken>=0.7.0
Requires-Dist: openai>=1.30.0
Requires-Dist: anthropic>=0.26.0
Requires-Dist: langchain>=0.2.0
Requires-Dist: langgraph>=0.1.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: rich>=13.7.0
Requires-Dist: click>=8.1.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: python-dotenv>=1.0.0
Provides-Extra: dashboard
Requires-Dist: fastapi>=0.111.0; extra == "dashboard"
Requires-Dist: uvicorn>=0.30.0; extra == "dashboard"
Requires-Dist: sqlalchemy>=2.0.0; extra == "dashboard"
Requires-Dist: aiosqlite>=0.20.0; extra == "dashboard"
Requires-Dist: websockets>=12.0; extra == "dashboard"
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
Requires-Dist: black>=24.0.0; extra == "dev"
Requires-Dist: ruff>=0.4.0; extra == "dev"
Dynamic: license-file

# 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

```bash
pip install context-cut
```

## Quickstart (no API key needed)

```bash
python examples/no_api_key_example.py
```

## Usage — one decorator

```python
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

```bash
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

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

Open http://localhost:3000

## LangGraph integration

```python
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
