Record the provider-reported model on usage events when a router resolves an alias #1119
FabioLeitao
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem
With OpenAI-compatible routers and aliases (OpenRouter
auto, LiteLLM aliases, local gateways), the model Zero requested is often not the model that served the request. The response says which one did: the stream carriesmodel, and Codex Responses carriesresponse.model. Zero drops that value. Sozero usage reportand the session log can only say "requestedauto", never which model actually answered or how usage split across models over time.Behavior I'm proposing
Usage.ResolvedModelwhen the stream provides it (OpenAI-compatible chunks and Codexresponse.model). When a stream reports usage across several chunks, the last non-empty value wins.resolvedModelkey onusageevents, through the existing single writerusage.EventUsagePayload. It is omitted when empty, so older readers and payloads are unaffected.modelkey. Cost still comes from the session's configured model through the registry, exactly as today.resolvedModelis attribution, not billing.Why it belongs in Zero
Zero already persists usage for local accounting. This makes that record truthful when routing is involved, at no cost when it is not. It is provider-agnostic: any router that echoes
modelbenefits, and nothing is provider-specific.Alternatives considered
modelwith the resolved value would change pricing and break escalation attribution, which is why it is a separate key.zero usage reportunable to use it.Status
Implemented and tested on my fork:
feat/resolved-model-usageon FabioLeitao/zero (448cc575), one commit onmain(99721c76), 11 files, +129/-1, mostly tests.make fmt-check,go vet ./...andgo test -raceonproviders,usage,zeroruntimeandclipass. I will open an issue or PR only if the core team wants it.All reactions