ContextClip (Python)
Ported line-for-line from the TypeScript implementation. See the root README for the pitch, the prior-art table, and the scope decisions — this file only covers what's specific to running the Python code.
Install
pip install -e ".[dev]"
Quickstart
PYTHONPATH=src python3 examples/quickstart.py
from contextclip import ContextClipper
clipper = ContextClipper(budget_tokens=200, tail_messages=2)
status = clipper.check(messages)
if status.action == "over_hard_limit":
result = await clipper.recover(messages)
# result.action is "drained" or "summarized" — result.messages never
# touches the last `tail_messages` of the original list.
Test
pytest
Status
Budget tracking, threshold checks, and staged drain-then-summarize
recovery with tail preservation are real and tested. Not yet published to
PyPI — contextclip is unclaimed there.
Release files for contextclip 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| contextclip-0.0.2.tar.gz | 5.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| contextclip-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.0 kB
Release files / contextclip-0.0.2.tar.gz
| Download URL | contextclip-0.0.2.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
92c5a235d10d480f869b3d85a00c17095324c23a48ceff73d11267daa4083cc5
|
|
BLAKE2b-256 checksum How to use checksums |
2ff72a026868ecf450549204d77f0bd87090f8779c6955db6bfa23e96afa23a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.8
|
Release files / contextclip-0.0.2-py3-none-any.whl
| Download URL | contextclip-0.0.2-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
826235f9a2d5e595a2143499237ddfd2bee3040adad3b33094f749ea3c229062
|
|
BLAKE2b-256 checksum How to use checksums |
89352fd4519606f7e1039af5892f2bc679ecc010e95ae8eef4113045b983d9f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.8
|