Repository navigation
fix(usage): retain response models through Chat fallbacks - #8728
Merged
Wei-Shaw merged 1 commit intoNov 16, 2026
Merged
Conversation
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Closes #8708.
The shared Chat Completions pipeline observes the upstream response model, but the Messages and Responses bridges drop that model and its conflict flag when constructing forwarding results. Usage records therefore lose the declared model and mismatch flag even though the upstream reported them.
Carry the existing observer's two fields through all seven result constructors, including read-error and invalid-tool-argument returns. The response tier and protocol conversion continue to use their existing values and rules.
Validation on Go 1.27.4 / macOS arm64:
main(530c5e3a): 15 of 19 targeted leaf cases fail; patched: 19/19 pass. Tests the actual Messages/Responses entry points through the shared Chat pipeline andRecordUsage, with buffered/streaming output, missing and conflicting declarations, read errors, client disconnects and invalid tool arguments.go test -p=2 -tags=unit ./internal/service -count=1: 18,779 pass / 10 conditional skips (test/subtest entries).go test -p=2 -tags=integration ./internal/service -count=1: 9,321 pass / 3 conditional skips (test/subtest entries).0 issues.Usage writes are captured by an in-memory repository; no live provider, production database or user deployment was exercised. The shared Go toolchain upgrade remains tracked by #8670.
AI disclosure: implemented and tested autonomously by an AI agent, without human review.