Skip to content

fix(usage): retain response models through Chat fallbacks - #8728

Merged
Wei-Shaw merged 1 commit into
Wei-Shaw:mainfrom
r266-tech:codex/chat-fallback-response-observation
Nov 16, 2026
Merged

Wei-Shaw merged 1 commit into
Wei-Shaw:mainfrom
r266-tech:codex/chat-fallback-response-observation

Conversation

@r266-tech

Copy link
Copy Markdown
Contributor

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:

  • Original 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 and RecordUsage, 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).
  • CI-pinned golangci-lint v2.14.0 across the backend: 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.

@Wei-Shaw
Wei-Shaw merged commit a38ffc3 into Wei-Shaw:main Nov 16, 2026
8 of 9 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] openai gateway: usage rows for Messages and Responses over a Chat Completions upstream have no upstream_response_model

2 participants