🙌 Open to contribution
Token spend deserves the same first-class attention as compute or latency, and
we are growing the community working on that. Policies, actuators, and the
shared ledger are all open to extension. See
CONTRIBUTING.md to get started.
✨ Core features
An AI agent's workflow can run up cost fast: dozens of small, individually
cheap steps that quietly add up to a surprisingly large bill. TokenOps sets
a single budget for the whole workflow and enforces it before every step,
so spending never gets away from you.
Ten policies ship configured in docs/policies/, and you can
add your own.
🚀 Quickstart
Requires Python 3.10+. Zero-setup taste: python -m tokenops.demo runs a governed
agent in process, no server and no keys. For your own agent in one process, pass a
governance config; to share one budget across processes, point every agent at a
control plane (see Quickdeploy below):
1. Put it in your agent
[!TIP]
Recommended. Your coding assistant reads
SKILL.md, wires the one
enforcement point into your agent, and tells you what to check.
In Claude Code, from a clone:
/integrate-tokenops
Anywhere else (Cursor, Copilot, ...), paste this:
Integrate TokenOps into this agent, following
https://github.com/theagentplane/tokenops/blob/main/.claude/skills/integrate-tokenops/SKILL.md
Manual, about ten lines
Wrap your model call once, then hand the wrapped version to your agent.
from tokenops import tokenops_run
from tokenops.capabilities import wrap_complete
from tokenops.framework import Halt
from tokenops.providers import complete
GOVERNANCE = {"governance": {
"budgets": [{"id": "run_llm_cap", "limit_micros": 2_000_000, "dimension": "trace"}],
"policies": {"cost_budget": {"budget": "run_llm_cap"},
"pre_call_worst_case": {"budget": "run_llm_cap"}},
}}