Skip to content

refactor(coderd/x/chatd/chatprovider): drop the direct Bedrock client - #30928

Draft
ibetitsmike wants to merge 2 commits into
mainfrom
mike/chatd-gateway-only-providers
Draft

ibetitsmike wants to merge 2 commits into
mainfrom
mike/chatd-gateway-only-providers

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

chatprovider.ModelFromConfig builds the fantasy client for every chat model call. Production reaches it only through the in-process AI Gateway, where fantasyConfigForAIBridge asks for the Anthropic, OpenAI, or OpenAI-compatible client, never Bedrock. This PR deletes the direct Bedrock client that ModelFromConfig could still build, ProviderAllowsAmbientCredentials and the API key bypass it fed, and the tests that drove that client.

Why it is safe

  • Outside tests, rg -n 'chatprovider\.ModelFromConfig\(' coderd enterprise cli scaletest aibridge finds one caller, newLanguageModel in model_routing_aibridge.go. It passes the hint and placeholder key from fantasyConfigForAIBridge, which sends Bedrock providers through the Anthropic or OpenAI client by model ID. The gateway signs Bedrock requests itself (aibridge/intercept/awssig).
  • ProviderAllowsAmbientCredentials had one caller, the key check in ModelFromConfig. The gateway path always sets the placeholder key, so the check becomes apiKey == "".
  • The deleted tests (3 of 4 TestModelFromConfig_Bedrock subtests, ...BedrockStripsAnthropicHeaders, ...BedrockStreamingHeaders, ...BedrockBetaExtraHeader, two helpers) each built the direct Bedrock client, so they guarded deleted code.
  • The OpenAI and Anthropic rows of the surviving subtest, NonBedrockStillRequiresAPIKey, move into TestModelFromConfig_MissingAPIKey. Its new bedrock row pins the generic error message that a deleted subtest checked. These mutants all fail it: no empty-key check, a changed generic message, a nil error from the generic arm. A garbage copy of the file fails to build, so the -overlay applies.

Review focus

Ambient credentials still decide provider availability in ResolveUserProviderKeys. Only the client-side bypass goes away.

Validation

  • go test ./coderd/x/chatd/chatprovider/... ./coderd/x/chatd/chatopenai/...: pass.
  • go test ./coderd/x/chatd/ -run 'AIBridge|AIGateway|Model|Provider|Bedrock|Quickgen|Title|Subagent' -p 4 -parallel 4: pass.
  • make pre-commit: pass.

Stack

This stack removes provider code that only direct, non-gateway clients used, so chatprovider builds just the three clients the AI Gateway path needs, then derives the BYOK auth header from that same client choice.

  1. refactor(coderd/x/chatd/chatprovider): drop the direct Bedrock client #30928 Drop the direct Bedrock client
  2. refactor(coderd/x/chatd): drop the remaining direct provider clients #30929 Drop the remaining direct provider clients
  3. refactor(coderd/x/chatd/chatprovider): drop provider options only direct clients read #30958 Drop provider options only direct clients read
  4. refactor(coderd/x/chatd): drop transport branches only direct clients used #30966 Drop transport branches only direct clients used
  5. test(coderd/x/chatd): cover BYOK header choice for Bedrock and OpenAI-compatible routes #30978 Cover the BYOK header choice for Bedrock and OpenAI-compatible routes
  6. Share the AI Gateway client choice with BYOK auth (next)

Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description.

Production builds every chat model through the in-process AI Gateway,
which only uses the Anthropic, OpenAI, and OpenAI-compatible clients.
ModelFromConfig still built a direct fantasy Bedrock client and let
Bedrock skip the API key check for ambient AWS credentials. Delete the
Bedrock arm, ProviderAllowsAmbientCredentials, and the tests that drove
the direct client.
@ibetitsmike
ibetitsmike added this pull request to stack #30930 October 18, 2026 15:13
@ibetitsmike ibetitsmike changed the title mike/chatd gateway only providers refactor(coderd/x/chatd/chatprovider): drop the direct Bedrock client Oct 18, 2026
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T15:38:40.459064Z 84a1253 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 84a125311a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant