Repository navigation
refactor(coderd/x/chatd): derive the BYOK auth header from the AI Gateway client choice - #30979
Draft
ibetitsmike wants to merge 3 commits into
Draft
ibetitsmike wants to merge 3 commits into
ibetitsmike wants to merge 3 commits into
Conversation
…eway client choice
ibetitsmike
added this pull request to stack #30930
October 18, 2026 16:39
This was referenced Oct 18, 2026
Collaborator
Author
|
@codex review
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This branch has not been deployed
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.
fantasyConfigForAIBridgepicked the fantasy client for an AI Gateway route, andaiGatewayRequestFormatForProviderTypemapped the same provider type and model again, only to chooseX-Api-KeyorAuthorization: Bearerfor a user's own key. This PR moves the client choice intoaibridgeClientProviderand passes its result toaiGatewayProviderAuthForUser, so the header follows the client. It deletes the request-format enum, the mapper, the mapper's test, and the supersededTestNewModelAttribution.Why it is safe
aibridgeClientProvideris the oldfantasyConfigForAIBridgeswitch without the base URL.TestAIBridgeProviderFormatMapping(12 rows, unchanged) still pins the client and base URL; the mapper test's 9 rows are a subset of them.TestAIGatewayProviderAuthForUserand the test(coderd/x/chatd): cover BYOK header choice for Bedrock and OpenAI-compatible routes #30978 subtest pin the header.TestNewModelAttributionImmutablePerRequestcovers both workspace bindings thatTestNewModelAttributionchecked, plus the API key ID, also without a database.go test -overlayeach fail a remaining test: every arm ofaibridgeClientProviderand the base URL check; an auth switch keyed onopenai, an auth case matchingopenai-compatinstead ofanthropic, and a dropped model ID at theresolveAIGatewayRoutecall; the workspace check, the workspace ID copy, and an empty API key ID. A garbage copy fails to build, so the overlay applies.rg -n 'aiGatewayRequestFormat' .finds nothing.Review focus
Only the Anthropic client gets
X-Api-Key;openaiandopenai-compatkeepAuthorization: Bearer, as the old default format gave them. Only the #30978 subtest catches an auth switch keyed onopenai.Validation
go test ./coderd/x/chatd/... -count=1 -p 4 -parallel 4: pass.make pre-commit: pass.Stack
This stack removes provider code that only direct, non-gateway clients used, so
chatproviderbuilds just the three clients the AI Gateway path needs; #30979 then derives the BYOK auth header from that same client choice.