agent-cop
Context recovery for AI agents. Analyze fatigue, compress context, improve token efficiency.
from agent_cop import analyze, recover
# Detect context bloat
report = analyze(messages)
# → { fatigue_score: 73, issues: [...], ... }
# Recover with algorithmic compression (free, no API key needed)
result = await recover(messages, budget_ratio=0.4)
# → { messages: [...], stats: { compression_ratio: "62.3%", ... } }
# Recover with LLM-based deep summarization (requires openai key)
result = await recover(messages, deep=True, openai_api_key="sk-...")
Quick install
pip install agent-cop
For deep LLM summarization:
pip install "agent-cop[deep]"
API
analyze(messages)
Detect context fatigue and bloat in a message history.
recover(messages, budget_ratio=0.5, deep=False, openai_api_key=None)
Compress a message history to fit within a budget. Algorithmic by default (free). Pass deep=True with an OpenAI key for semantic LLM-based summarization.
LangChain integration
from agent_cop.langchain import CopCallback
from langchain.agents import AgentExecutor
callback = SpaCallback(threshold=0.8)
agent = AgentExecutor(..., callbacks=[callback])
# Auto-recovers context at 80% token usage
REST API
curl -X POST https://api.agent-spa.dev/v1/recover \
-H "x-api-key: $KEY" \
-H "Content-Type: application/json" \
-d '{"messages": [...], "budget_ratio": 0.4, "deep": true}'
Generate a free API key at https://agent-cop.dev.
License
MIT
Metadata
Release files for agent-context-recovery 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| agent_context_recovery-0.1.0.tar.gz | 6.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| agent_context_recovery-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.2 kB
Release files / agent_context_recovery-0.1.0.tar.gz
| Download URL | agent_context_recovery-0.1.0.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2c6a6a9fe3675b2d1a801cf3a158383bf0027a2444cb15f9767585a063aa43c6
|
|
BLAKE2b-256 checksum How to use checksums |
903377c4ec850d1f0cfd4e1bd93b0cf761fcad59e1a7a9aeccb54197252ad5a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.6
|
Release files / agent_context_recovery-0.1.0-py3-none-any.whl
| Download URL | agent_context_recovery-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a231ed0d1ac4b6794376b962d793816b22a08cdaeb061f5584d98695b54b7491
|
|
BLAKE2b-256 checksum How to use checksums |
8900448f10e798f2995cbcd90bb209edcdbef31cd0096f07a2fc04268eb805a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.6
|
Security for agent-context-recovery 0.1.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.