Repository navigation
feat(usage): persist resolvedModel on provider_usage events - #5
Merged
Merged
Conversation
Decode OpenAI-compatible stream `model` into Usage.ResolvedModel, merge on collect (last non-empty wins), and write `resolvedModel` in EventUsage payload without changing pricing `model` (registry.Require unchanged). PATCHSPEC_zero_resolved_model_attribution_2026-09-30; base 95c8fc1. GBCU: generic for any router echoing `model` — candidate for Gitlawb/zero upstream.
Zero automated PR reviewVerdict: No blockers found Blockers
Validation
ScopeHead: This deterministic review checks validation status and basic diff hygiene. A human reviewer still owns product judgment and design quality. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
modelfrom OpenAI-compatible streaming chunks intoUsage.ResolvedModel, merge on collect (last non-empty wins), and persist asresolvedModelonprovider_usageevents.model(registry.Require/CalculateCostunchanged); observability only (omitempty)./responsespath setsResolvedModelfromresponse.modelwhen present.upstream/mainat99721c76(OpenCode session headers fix(providers): send stable session headers to OpenCode Twigpine/zero#1060) alongside this change.Motivation
Routed providers (e.g.
openrouter/free) need per-prompt attribution of the concrete model that served the request (herding-vicuna measurement). PATCHSPEC:PATCHSPEC_zero_resolved_model_attribution_2026-09-30(operator vault).Test plan
go test ./internal/providers/openai ./internal/usage ./internal/zeroruntime(incl. new unit tests)make lintmake vulncheck— no vulnerabilitiesgo build -o zero-patched ./cmd/zeroPre-existing / environment (not blocking this PR)
TestResolveReportsExplicitMaxTurns(internal/config) fails identically on isolated bases without this patch:a4a83049,95c8fc14,9e609c52(feat(exec): default headless runs to the turn-budget ceiling Twigpine/zero#1049),99721c76(fix(providers): send stable session headers to OpenCode Twigpine/zero#1060), and this branch — same error:no active provider configured: active provider "" not foundon subcasebuilt-in default only.resolvedModelor merge fix(providers): send stable session headers to OpenCode Twigpine/zero#1060; no edits to that test.Local Lynis umask
0007: permission-sensitive tests need( umask 0022; make test ); with0022, onlyconfig(above) +tuiTestRelativeAgeFormatsLastActivityremain red (also unrelated to this diff).make lint-static: 4 staticcheck QF* onmain(unchanged).gosec ./...: repo baseline exit 1 (331 issues); none in touched paths.Upstream (GBCU)
Generic for any router echoing
model— propose to Gitlawb/zero via Discussions after merge here (no PR to upstream in this change).