Skip to content

usage: attribute compaction-model and fallback tokens to the model that spent them #345

Open

Description

@lydakis

Follow-up from #302 (Codex finding, #302 (comment)).

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.

Activity

  1. lydakis commented on Oct 29, 2026

    @lydakis
    OwnerAuthor

    #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.


    Generated by Claude Code

  2. lydakis commented on Oct 31, 2026

    @lydakis
    OwnerAuthor

    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.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions