Token and cost tracking harness for AgenticStack: per-agent usage, USD estimates, and budgets
Project description
agenticstack-costs
Token and cost tracking harness for AgenticStack.
Accumulates prompt/completion/total tokens, call counts, and estimated
USD spend per agent (and overall) by watching every LLM call through
MONITOR-priority hooks — the same interception surface every
marketplace plugin uses. Nothing is transformed; it only counts.
Install
pip install agenticstack-costs
Use
from agenticstack_costs import CostTracker
tracker = CostTracker(budget_usd=5.00).install()
# ... run any agents ...
print(tracker.report())
# {
# "per_agent": {"Helper": {"calls": 3, "prompt_tokens": 2100,
# "completion_tokens": 640, "total_tokens": 2740,
# "cost_usd": 0.0021}},
# "total": {..., "runs": 3},
# "unpriced_calls": 0,
# "over_budget": False,
# }
tracker.reset() # zero the counters
tracker.uninstall() # detach cleanly
Or as a plugin (CostsPlugin), activated by the plugin runtime; pass
budget_usd through plugin config.
Pricing table
PRICES maps model-name prefixes to (input, output) USD per 1M tokens
for gpt-4o, gpt-4o-mini, claude-3-5-sonnet, claude-3-5-haiku,
gemini-1.5, and llama. The longest matching prefix wins
(gpt-4o-mini-2024... prices as gpt-4o-mini, not gpt-4o). The
numbers are estimates of public list prices — verify against your
provider before relying on them. Models with no matching prefix cost
0.0 and increment the unpriced_calls counter.
Budgets are soft
budget_usd is tracking only: when the estimated total exceeds it, the
tracker logs a warning and sets over_budget = True. It never blocks
or stops anything — pair it with a guard plugin if you need hard
enforcement.
Permissions
None — pure in-memory accounting.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
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 agenticstack_costs-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agenticstack_costs-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b60d3fcab3ee9a10a554aef9d7a362ba4015cb52773030d06630133624d5a3c
|
|
| MD5 |
08f01b5596db2b1cbc2ddd0f3c6d8b79
|
|
| BLAKE2b-256 |
4d3228cfabc73e554c635b1637514b20b630fe8de5af579b667c90defe4402fe
|