This release is a pre-release and may not be stable for production use.
tokentriage — Python instrumentation SDK
The zero-dependency, never-throws, no-phone-home helper for the
TokenTriage proxy. It forwards and
reads; it never computes. Every x-tt-* recipe is a one-liner, and every number
on display is server-truth — a value the server did not disclose is a first-class
absent, never $0.00, never a client-side estimate.
- Zero runtime dependencies (
dependencies = [], enforced in CI). - Never throws on the host path — every public entry is shielded; render-time inputs coerce-or-drop, never raise.
- No phone-home — the core opens no sockets; the optional ledger module (SDK2) talks only to your own admin plane.
import tokentriage as tt
tt.init(base_url="http://127.0.0.1:8787")
with tt.trace(agent="triage", user="u-42", tenant="acme", feature="chat"):
with tt.step(step_class="user_turn"):
headers = tt.headers(tags={"env": "prod"}) # the wire artifact
resp = your_llm_client.post(..., headers=headers)
rcpt = tt.receipt(resp) # typed, read-only
print(rcpt.mode, rcpt.decision, rcpt.cost_display)
print(rcpt.dashboard_url()) # deep link to the ledger record
The honest dollar lives in the ledger row keyed by rcpt.request_id
(cost_display points you there); the SDK never fabricates one inline.
Status
The full v1 surface is implemented and gated. That is: context/identity, the wire
layer (header render + receipt parse), the closed three-state Cost,
config/diagnostics/shield; the transport adapters (httpx/requests) and the
LangChain/CrewAI adapters; the ledger pull (ledger.fetch/fetch_trace) and the
feedback write (ledger.feedback); the first-run doctor tt.check(); the OpenTelemetry
bridge; and the adopter test kit — all against a byte-equality conformance corpus shared
with the TypeScript binding.
Pre-1.0: the two bindings are being brought to a single shape before the surface
freezes, so a few names are still moving. See the CHANGELOG's [Unreleased] section.
Development
python -m venv .venv && . .venv/Scripts/activate # Scripts/ on Windows, bin/ on POSIX
pip install -e ".[dev]"
pytest -q # unit + conformance + properties (+ e2e when Go is present)
Licensed under Apache-2.0. See LICENSE and NOTICE.
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 tokentriage-1.0.0rc1.tar.gz.
File metadata
- Download URL: tokentriage-1.0.0rc1.tar.gz
- Upload date:
- Size: 434.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70437b4f392c81a54e6c9c5bf8f0d577c9f8d96b5ab65363237b592ab9c4b58b
|
|
| MD5 |
f810acc97b03fae27d6f5e29146a1391
|
|
| BLAKE2b-256 |
8b526826b5879d7654b3575a18b1eadea0b5aad07f6d62d7624053018ce789af
|
File details
Details for the file tokentriage-1.0.0rc1-py3-none-any.whl.
File metadata
- Download URL: tokentriage-1.0.0rc1-py3-none-any.whl
- Upload date:
- Size: 288.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96fc2b91eac77a3a14c57e174d1050789d443297eb1bbc3da16db8984d9e7e41
|
|
| MD5 |
3e72e514efe275265a4749af1d0e1f5a
|
|
| BLAKE2b-256 |
10c77f2bb785bf864de99858faf8a62e8b381b256f124071f9c9ee03d9c93409
|