Model cost accounting and per-agent budgets (Milestone C). Every model call records its token usage and dollar cost on the `model.call` audit event. This module is the math and the read side: price a call from a config rate table, roll spend up per agent over a time window, and r
# Source: https://github.com/JIGGAI/JIGGA | License: MIT | Copyright 2026 JIGG AI
# Provided via justclaw.it.com; keep this notice with the code.
"""Model cost accounting and per-agent budgets (Milestone C).
Every model call records its token usage and dollar cost on the `model.call`
audit event. This module is the math and the read side: price a call from a
config rate table, roll spend up per agent over a time window, and resolve an
agent's budget into an ok / warn / exceeded status. Enforcement lives in
`model_router.call_model` (the single chokepoint for model spend); it uses
`agent_budget` + `agent_spend` from here to hard-stop at the cap and the
`WARN_FRACTION` threshold to soft-warn on the way up.
Pricing and budgets are config, not code:
models:
pricing:
gpt-4o
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key