litellm-paritok
Paritok context compression as a LiteLLM Proxy callback.
Drop one line in your LiteLLM Proxy config and every request through the proxy is
compressed before it hits the upstream provider — tool-schema filtering, file/tool-output
compression, history compression, non-destructive recall (read_original /
gateway_search_tools), and Edit-recovery — with zero changes to your agent or app.
Scope: this works under LiteLLM Proxy. The hooks it uses (
async_pre_call_hook/async_post_call_success_hook) are proxy-only, so the bare SDK path (import litellm; litellm.completion(...)) is not intercepted. See Limitations.
Install
pip install litellm-paritok # pulls in `paritok`
You also need a Paritok 4B compression backend (either one):
ollama pull paritok/paritok-4b-v1 # local Ollama, on your own machine
# or point Paritok at a hosted GPU server via an API key
Use
Add one line to your LiteLLM Proxy config.yaml:
litellm_settings:
callbacks: ["litellm_paritok.paritok_handler"]
Then run the proxy as usual; your app keeps pointing at LiteLLM:
litellm --config config.yaml
The callback string is a dotted path
module.instance, resolved by LiteLLM'sget_instance_fn. Uselitellm_paritok.paritok_handler(a ready-made instance this package exports) — not a bare"paritok", which LiteLLM would try to import as a module.
How it works
The package is a thin CustomLogger over the published paritok engine — the same
compression/recall/recovery algorithms that power the Paritok proxy, wired to LiteLLM's
hooks:
async_pre_call_hook→ParitokEngine.process_request(...): filters tool schemas, compresses file reads / tool outputs / old history, injects the virtual recall tools, and returns the modified request for the upstream call.async_post_call_success_hook→ recall resolve-loop + Edit recovery: answers anyread_original/gateway_search_toolscalls itself (re-requesting the model vialitellm.acompletionuntil a plain turn returns), then rewrites anyEditwhoseold_stringwas authored against a lossy summary so it matches the real file byte-for-byte.
Limitations
- Proxy-only. The bare LiteLLM SDK path does not trigger these hooks. SDK coverage would need a separate wrapper / custom provider.
- Requires a Paritok 4B backend (Ollama or hosted GPU) — the prerequisite for any Paritok deployment, not specific to this integration.
Development
pip install -e ".[dev]"
PYTHONPATH=. pytest tests/ -v
Licensed under Apache-2.0.
Metadata
Release files for litellm-paritok 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 | |
|---|---|---|---|
| litellm_paritok-0.1.0.tar.gz | 15.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| litellm_paritok-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.8 kB
Release files / litellm_paritok-0.1.0.tar.gz
| Download URL | litellm_paritok-0.1.0.tar.gz |
|---|---|
| Size | 15.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
39d44b4220b82fa5848b42dc0ab33f5527580238ba68d3b155d038b6005baf59
|
|
BLAKE2b-256 checksum How to use checksums |
e82ccf9a6bb42e1b9a8fb317d4ae4f7e5df5edf4b6b06dd770d472b188edfb93
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / litellm_paritok-0.1.0-py3-none-any.whl
| Download URL | litellm_paritok-0.1.0-py3-none-any.whl |
|---|---|
| Size | 14.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5e069d203b99f56fb2625ed7729eb32f113b02786ff8550e02712f7d3940247f
|
|
BLAKE2b-256 checksum How to use checksums |
5e3565c990ff765c3ebf22e1e06d03d5cb3cb174b561a7e90c0ec5d7fdd1de29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|