feat: route extra ai_provider_types through OpenAI and Anthropic providers#25722
Conversation
Docs preview📖 View docs preview for |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
/coder-agents-review |
|
Review posted | Chat Review historydeep-review v0.5.0 | Round 2 | Last posted: Round 2, 13 findings (4 P2, 6 P3, 2 Nit, 1 Note), COMMENT. Review Finding inventoryFindings
Contested and acknowledged(none) Round logRound 1Netero-only. 2 P2, 1 P3. Reviewed against 958c96b..42de9f5. Round 2Churn guard: PROCEED. CRF-1, CRF-2, CRF-3 addressed in d3073ca. Panel round (12 reviewers). Netero: 1 new P3 (CRF-4). Panel: 2 P2, 4 P3, 2 Nit, 1 Note new. 0 dropped. Reviewed against ae49249..2ba66c2. About deep-reviewCRF = Coder Review Finding (P0-P4, Nit, Note)
|
There was a problem hiding this comment.
First-pass review (Netero). Two test coverage gaps and one stale comment. The full review panel has not yet reviewed this PR; it will review after these findings are addressed.
2 P2, 1 P3.
🤖 This review was automatically generated with Coder Agents.
… providers
Widens buildAIProviderFromRow so the non-native ai_provider_type enum
values route through the existing fantasy clients:
- azure, google, openai-compat, openrouter, vercel -> OpenAI provider
(chatd configures these against their OpenAI-compatible endpoints).
- bedrock -> Anthropic provider with a Bedrock discriminator in
Settings. A bedrock row without populated Bedrock credentials is
rejected rather than falling back to an unsigned Anthropic client.
Native gateway-side support for any of these arrives later. Adds test
rows covering each new type via the APIDumpDir dispatch test.
958c96b to
ae49249
Compare
d3073ca to
2ba66c2
Compare
|
Addressed all three review findings in d3073ca:
|
|
/coder-agents-review |
There was a problem hiding this comment.
Panel review (round 2, 12 reviewers). R1 findings all fixed cleanly in d3073ca.
The routing logic is correct and well-documented. Mafu-san noted consistent enumeration across all four switch sites, and the vercel-to-"not-a-real-provider" test fix shows good sibling awareness. Two substantive gaps surfaced: the API validation path doesn't enforce bedrock invariants that the env path does, and the new test entries verify construction but not routing correctness.
2 P2, 5 P3, 2 Nit, 1 Note.
Pariston: "The premises of this PR hold. The routing is correct, the validation covers the important paths, and the tests verify the new behavior. I tried to build a case that a simpler solution exists and couldn't."
codersdk/aiproviders.go:63-64
P3 [CRF-7] Doc comment says "Only meaningful for AIProviderTypeAnthropic" but the PR makes this field meaningful for AIProviderTypeBedrock too.
The analogous comments in coderd/ai_providers.go (lines 323, 490) and coderd/ai_providers_migrate.go (line 350) were all updated. This one was missed.
Fix: // Only meaningful for AIProviderTypeAnthropic or AIProviderTypeBedrock.
(Gon P2, Hisoka P3, Mafuuu P3)
🤖
codersdk/deployment.go:4701
P3 [CRF-8] Bedrock field comment says only applicable when Type == "anthropic" but the PR makes these fields applicable to "bedrock" too. The Type comment five lines above was updated; this one was missed.
Fix: // Bedrock fields (applicable when Type is "anthropic" or "bedrock").
(Leorio P2, Mafuuu P3, Meruem Nit)
🤖
cli/aibridged.go:240
Nit [CRF-11] The OpenAI arm (line 208) was updated to xerrors.Errorf("%s key pool: %w", row.Type, err). This Anthropic/Bedrock arm still hardcodes "anthropic key pool". Unreachable for bedrock rows today (the nil-credentials guard fires first), but inconsistent with the pattern three lines above.
(Chopper P3, Gon P3, Kite Nit, Mafuuu Nit)
🤖
🤖 This review was automatically generated with Coder Agents.
- CRF-5: Validate() now rejects type=bedrock without bedrock settings and with api_keys - CRF-6: TestBuildAIProviderFromRowSetsAPIDumpDir asserts provider.Type() to verify routing correctness - CRF-4: add TestBuildAIProviderFromRowBedrockWithoutSettings for the error path - CRF-9: fix Provider field comments to document runtime type column (openai, anthropic, copilot) instead of all db types - CRF-10: replace manual type validation switches with Valid() and AllAIProviderTypeValues() in cli/server.go and ai_providers_migrate.go - CRF-12: extract providerType variable to eliminate repeated casts
- Use early-return pattern in ai_providers_migrate.go (revive lint) - Remove extra blank line in mustMarshalSettings (revive lint)

Disclosure: produced with Claude Opus 4.7
AI Gateway only supports Anthropic (+Bedrock), OpenAI, and Copilot providers at present. All other types (Vercel, Gemini, etc) will be mapped to OpenAI since they support OpenAI-compatible endpoints.