You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
usage: attribute compaction-model and fallback tokens to the model that spent them #345
usage groups each turn's totals under the turn's model. When a bot has a compaction model different from its own, or Anthropic fallbacks turned on, those tokens count under the turn's model. The real split lives only in usage events (models, summarizer_usage), and events get pruned.
Sonny sets neither option today, so its /usage is accurate. Bots run from the agent CLI with --compaction-model or --fallbacks are not.
A fix would keep the split durably, for example in a per-turn-per-model table written with the usage. That table is written on the turn path, so it needs a perf screen.
#349 changes the fallback half of this, though it doesn't fix it:
--fallbacks (Anthropic's server-side fallback) is gone. In its place, --fallback PROVIDER/MODEL makes the daemon retry a refused request on that model, once, and the next request goes back to the bot's model.
That retry's usage event names the fallback's provider and model in models, priced the same way summarizer calls are (priced_at, formerly summarizer_usage). So the split is right in events, but turn totals still count it under the turn's model, as this issue describes.
Sonny can now set a fallback: [fallbacks] in ~/.agent/config.toml applies to new leads and tasks. A configured fallback that actually fires will make Sonny's /usage slightly off too. Fallback calls only happen when a request is refused, so they should be rare.
The durable per-turn-per-model split proposed here would cover both cases. It stays a separate change with its own perf screen.
Scope update: the earlier note that Sonny is unaffected no longer holds. Sonny now sets a fallback from [fallbacks] in ~/.agent/config.toml when it makes an agent (sonny --new, and trigger --start agents from now on), so fallback tokens can be counted against the wrong model there too.
Activity
lydakis commentedon Oct 29, 2026
#349 changes the fallback half of this, though it doesn't fix it:
--fallbacks(Anthropic's server-side fallback) is gone. In its place,--fallback PROVIDER/MODELmakes the daemon retry a refused request on that model, once, and the next request goes back to the bot's model.usageevent names the fallback's provider and model inmodels, priced the same way summarizer calls are (priced_at, formerlysummarizer_usage). So the split is right in events, but turn totals still count it under the turn's model, as this issue describes.[fallbacks]in~/.agent/config.tomlapplies to new leads and tasks. A configured fallback that actually fires will make Sonny's/usageslightly off too. Fallback calls only happen when a request is refused, so they should be rare.The durable per-turn-per-model split proposed here would cover both cases. It stays a separate change with its own perf screen.
Generated by Claude Code
lydakis commentedon Oct 31, 2026
Scope update: the earlier note that Sonny is unaffected no longer holds. Sonny now sets a fallback from
[fallbacks]in~/.agent/config.tomlwhen it makes an agent (sonny --new, and trigger--startagents from now on), so fallback tokens can be counted against the wrong model there too.Generated by Claude Code