Skip to content

agent: spend guardrails — sonnet default, usage report, token budget - #233

Merged
NickFlach merged 1 commit into
mainfrom
agent/spend-guardrails
Jul 21, 2026
Merged

agent: spend guardrails — sonnet default, usage report, token budget#233
NickFlach merged 1 commit into
mainfrom
agent/spend-guardrails

Conversation

@NickFlach

Copy link
Copy Markdown
Collaborator

Fixes the uncontrolled API spend from live agent runs (2026-07-20 drain): the Anthropic path defaulted to claude-opus-4-8 with zero usage visibility and no cumulative cap.

  • Default model → claude-sonnet-5 (near-Opus agentic quality, $3/$15 vs $5/$25 per MTok). Opus 4.8 / Fable 5 stay one flag away (--model / QOS_CLAUDE_MODEL).
  • Per-run usage report: input/output/cache-read/cache-write token totals + sticker-price estimate printed at exit of every run.
  • --token-budget (default 400k, QOS_TOKEN_BUDGET, 0 = unlimited): cumulative token cap that halts the loop mid-run. --max-turns bounds turns but not tokens-per-turn; this bounds the actual spend.

🤖 Generated with Claude Code

… budget

The BYO-key agent's Anthropic path defaulted to claude-opus-4-8 with no
usage visibility, so live loops silently billed Opus rates per turn
(each turn ships 22 tool schemas + the growing conversation + VM
output). Three guardrails:

- default model claude-opus-4-8 -> claude-sonnet-5 (near-Opus agentic
  quality at 3/15 vs 5/25 per MTok); Opus/Fable remain one flag away
  via --model / QOS_CLAUDE_MODEL
- per-run usage accounting: input/output/cache tokens accumulated per
  turn and printed at exit with a sticker-price spend estimate
- --token-budget (default 400k, env QOS_TOKEN_BUDGET, 0 = unlimited):
  cumulative token cap that stops the loop mid-run, complementing the
  --max-turns cap which bounds turns but not tokens-per-turn

Co-Authored-By: Claude Fable 5 <[email protected]>
@NickFlach
NickFlach merged commit dbace10 into main Jul 21, 2026
25 checks passed
@NickFlach
NickFlach deleted the agent/spend-guardrails branch July 21, 2026 04:26
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