Skip to content

fix(usage): retain native Anthropic response observations - #8727

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

Wei-Shaw merged 1 commit into
Wei-Shaw:mainfrom
r266-tech:codex/native-anthropic-response-observation

Conversation

@r266-tech

Copy link
Copy Markdown
Contributor

Closes #8719.

The native Anthropic Messages path observes the upstream model and processing tier, then drops those observations when building its buffered and streaming OpenAIForwardResult. Usage records consequently lose the declared model and mismatch flag; channels configured to bill by a trusted response model also fall back to the sent model.

Carry the existing observer's model, conflict flag and response tier into both result constructors, including partial-stream results. Reuse the current normalization, conflict handling and pricing rules.

Validation on Go 1.27.4 / macOS arm64:

  • Original main (530c5e3a): 10 of 14 targeted leaf cases fail; patched: 14/14 pass. Tests the real ForwardAsAnthropic → RecordUsage → usage repository boundary, matching/mismatched/missing models, conflicting declarations, EOF/read errors, client disconnect, unchanged response bytes and billing-source behavior.
  • go test -p=2 -tags=unit ./internal/service -count=1: 18,775 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 repository writes are captured in memory; 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 32e4283 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 native Anthropic passthrough: upstream response model is not recorded in usage logs

2 participants