HeadlinesBriefing favicon HeadlinesBriefing.com

GitHub wattage: AI Agent Token Profiler & Cost Gate

Hacker News •
×

wattage is a Kill‑A‑Watt meter for AI agents. Point it at an OTLP JSON trace and it tells you exactly where tokens are burned, prices each waste pattern in real dollars, prescribes a fix, and can fail your CI when a change makes your agent measurably more expensive.

Install with `uvx wattage report trace.json` – no config, no API key, fully offline. The tool ingests a trace, prices every call against a dated snapshot, and runs eight detectors that flag inefficient patterns. A sample report shows Token Efficiency: A (100), Total cost: $0.0602, with a clean token breakdown.

The standout feature is the convergence engine, which catches loops that thrash or stall without real progress. Benchmarks show a classifier precision of 1.00 versus 1.00 for an exact‑match baseline, and a real trace demo saw a 44.7% cost reduction by enabling prompt caching on a stable prefix.

CI integration is seamless: a badge and a GitHub Actions workflow run wattage on every PR, compare against a committed baseline, and fail the build if the score drops below 80 or the cost increases by more than 5%. It posts a delta table as a PR comment and emits SARIF for security scanning.