Skip to content

feat(extensions): cost-tracker for per-agent cost aggregation#73

Merged
dgarson merged 3 commits intodgarson/forkfrom
feat/cost-tracker-2
Feb 23, 2026
Merged

feat(extensions): cost-tracker for per-agent cost aggregation#73
dgarson merged 3 commits intodgarson/forkfrom
feat/cost-tracker-2

Conversation

@dgarson
Copy link
Owner

@dgarson dgarson commented Feb 22, 2026

Summary

Add a new cost-tracker extension that provides per-agent cost tracking from telemetry JSONL.

Problem

15 discovery agents running 3 waves/day with zero per-agent cost/spend visibility.

Solution

  • New extension extensions/cost-tracker/ that reads from telemetry JSONL sink (additive, no upstream changes)
  • Model pricing table covering MiniMax M2.5, GLM-5, Grok 4, Claude Sonnet, Claude Haiku at minimum
  • Per-agent daily cost rollup - aggregates token usage × model pricing per agent
  • Budget alerts - logs warnings when daily/agent limits exceeded

Deliverables

  1. extensions/cost-tracker/ extension scaffold (package.json, index.ts, cost-aggregator.ts)
  2. ✅ Model pricing table (MiniMax M2.5, GLM-5, Grok 4, Claude Sonnet, Claude Haiku)
  3. ✅ Per-agent daily cost rollup function reading from telemetry JSONL
  4. ✅ Budget alert hook (logs warning when threshold exceeded)
  5. scripts/cost-report.ts — CLI script to print last 24h cost summary
  6. ✅ PR to feat/cost-tracker-2

Testing

# Test CLI script
npx tsx scripts/cost-report.ts --telemetryPath /path/to/telemetry

# With custom window
npx tsx scripts/cost-report.ts --telemetryPath /path/to/telemetry --hours 48 --json

Notes

  • TypeScript strict, ESM, no any types
  • ~200 LOC for core extension logic
  • Reads from existing telemetry JSONL format (same as cron_usage_report.ts)
  • Zero impact to existing extensions/services

- New extensions/cost-tracker module that reads telemetry JSONL
- Tracks per-agent API spend using token counts × model pricing
- Per-run cost (agent × wave) and daily/weekly rollups
- Budget guardrail alerts (configurable threshold)
- Model pricing table: MiniMax M2.5, GLM-5, Grok 4, Claude Sonnet, Haiku
- scripts/cost-report.ts CLI for last 24h cost summary

This is an additive extension with minimal impact to upstream code.
@dgarson dgarson merged commit 74139b0 into dgarson/fork Feb 23, 2026
2 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant