Implement Claude Code usage tracking and automatic fallback lanes
Build a spend-tracking system for Claude Code API usage (200 USD/mo budget at API rates) with automatic throttling and fallback to alternative agent lanes (Codex, Kimi) when Ant...
StateDoneNext ActionClosedOwnerLuciRuntimeClosedAge13d ago
Ticket is done; runtime is closed.·profile claude_opus_1m_medium · cwd /home/lucienne/workspace/mission-control/.claude/worktrees/pool-1 · uptime 11d 20h · last activity 11d 18h ago
Description
MC-4491
Build a spend-tracking system for Claude Code API usage (200 USD/mo budget at API rates) with automatic throttling and fallback to alternative agent lanes (Codex, Kimi) when Anthropic budget is approached.
## Acceptance Criteria
- [ ] Daily spend accumulator with JSON persistence
- [ ] Per-model cost tracking (haiku/sonnet/opus)
- [ ] Budget thresholds: warn at 70%, throttle at 85%, block at 95%
- [ ] Automatic fallback to Codex/Kimi when Anthropic budget hit
- [ ] Update cli-agent-coordinator skill with budget/turn limits
- [ ] Update claude-code skill with --max-budget-usd and --max-turns defaults
- [ ] All automated claude -p dispatches include cost tracking
- [ ] Telegram alert when daily/monthly thresholds crossed
Activity
done
INTERACTIVE
Luci is working...
Details —
Done
· High
· Luci
▼
SState
Done
Closed
PPeople
TTiming / Details▼
luci (luci)
Mission Control
13d ago
12d ago
Advanced / Operator evidence
RRouting owner
ROperator console
Ticket is done; runtime is closed.ticket_marked_doneprofile claude_opus_1m_medium · cwd /home/lucienne/workspace/mission-control/.claude/worktrees/pool-1 · uptime 11d 20h · last activity 11d 18h agoMC is visibility-only. Hermes Luci launches and gates work outside MC, then mirrors evidence/status here.Raw console: luci · claude/anthropic/opus[1m]
WWorkflow
Start Dev Review + QA ▾
Select phases to include:
Agents
Review Gates
Decision
WAT routing: choose an agent, review gate, or decision. Buttons use the live runtime when one is attached.
Controller triage: clear acceptance criteria, assigned to Luci. Moving to todo.
lucienne12d ago
Controller: unblocking — no active dependency. Clear acceptance criteria ready for dispatch.
lucienne12d ago
Controller: unblocking — no active dependency. Clear acceptance criteria ready for dispatch.
Luci12d ago
MC-4491 spend tracking + fallback lanes — built, tested (19 passing), committed + pushed to slot1/mc-MC-4491.
SHIPPED (mission-control repo):
- spend_tracker.py: per-model cost ledger ($200/mo Anthropic budget), JSON persistence at ~/workspace/state/spend/ (survives pool reset), thresholds warn70/throttle85/block95, one-shot Telegram alert per crossing, recommend_lane (Codex/Kimi), fallback-signal.json, CLI guardrail flags (--max-turns=40 / --max-budget-usd=5 defaults).
- models.append_cost_event: now derives real cost_usd from model+usage (fixes scheduler posting 0.0) AND feeds the ledger. This is the universal chokepoint every automated dispatch already hits — so cost tracking is automatic, no per-dispatcher change.
- runtime_picker.apply_budget_fallback / pick_runtime_with_budget: swap Anthropic profile → Kimi (throttle) / Codex (block).
- /api/v1/spend/status route.
TWO ACCEPTANCE ITEMS HIT SCOPE BOUNDARIES (your call):
1. "Update cli-agent-coordinator skill" + "Update claude-code skill" — neither skill exists on this box (checked active + _retired). Their substance (the --max-budget-usd/--max-turns defaults) shipped as code constants instead.
2. Automatic dispatcher-side swap: the decision API is ready+tested, but the swap must be invoked from mc_pickup.py / scheduler.py which live in the ~/workspace repo, NOT mission-control. Per pool-isolation (MC-4548) I don't edit ~/workspace from a pool slot. Filed as follow-up MC-4557.
Tracking + alerting + fallback mechanism are live now; the auto-swap wiring is the only remaining piece and is queued. Review the boundary calls.
lucienne12d ago
Controller: closing as done. Code merged to master (98731e9), 19/19 tests passing. Core acceptance criteria met: spend accumulator with JSON persistence, per-model cost tracking, budget thresholds (warn/throttle/block), fallback decision API, Telegram alerts, automatic cost tracking on all dispatches. Two items hit scope boundaries: skills don't exist on box (substance shipped as code constants), dispatcher wiring filed as MC-4557.