Skip to content

feat: route extra ai_provider_types through OpenAI and Anthropic providers#25722

Merged
dannykopping merged 4 commits into
mainfrom
dk/aibridge-providers-openai-compat
May 27, 2026
Merged

feat: route extra ai_provider_types through OpenAI and Anthropic providers#25722
dannykopping merged 4 commits into
mainfrom
dk/aibridge-providers-openai-compat

Conversation

@dannykopping
Copy link
Copy Markdown
Contributor

@dannykopping dannykopping commented May 27, 2026

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.

@github-actions
Copy link
Copy Markdown

Docs preview

📖 View docs preview for docs/reference/api/schemas.md

Copy link
Copy Markdown
Contributor Author

dannykopping commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

/coder-agents-review

@coder-agents-review
Copy link
Copy Markdown
Contributor

coder-agents-review Bot commented May 27, 2026

Review posted | Chat
Requested: 2026-05-27 11:06 UTC by @dannykopping
Spend: $34.96 / $100.00

Review history
  • R1 (2026-05-27), 2 P2, 1 P3, COMMENT. Review
  • R2 (2026-05-27): 12 reviewers, 2 Nit, 1 Note, 4 P2, 6 P3, COMMENT. Review

deep-review v0.5.0 | Round 2 | ae49249..2ba66c2

Last posted: Round 2, 13 findings (4 P2, 6 P3, 2 Nit, 1 Note), COMMENT. Review

Finding inventory

Findings

# Sev Status Location Summary Round Reviewer Posted
CRF-1 P2 Author fixed (d3073ca) cli/server.go:3051 Three bedrock-type validation branches in ReadAIProvidersFromEnv have zero test coverage R1 Netero Yes
CRF-2 P2 Author fixed (d3073ca) cli/aibridged.go:222 buildAIProviderFromRow bedrock arm (happy + error path) has no test coverage R1 Netero Yes
CRF-3 P3 Author fixed (d3073ca) coderd/ai_providers.go:488 Doc comment on errAIProviderBedrockTypeMismatch still says "not anthropic-typed" after sentinel now accepts bedrock R1 Netero Yes
CRF-4 P3 Open cli/aibridged.go:226 buildAIProviderFromRow bedrock-without-credentials error path has no test R2 Netero Yes
CRF-5 P2 Open codersdk/aiproviders.go:227 Validate() accepts type=bedrock without requiring bedrock settings or rejecting API keys R2 Hisoka P2, Meruem P2, Ryosuke P2, Kite P3 Yes
CRF-6 P2 Open cli/server_aibridge_internal_test.go:611 New provider test entries verify APIDumpDir but not routing correctness (provider.Type()) R2 Bisky P2, Chopper P3 Yes
CRF-7 P3 Open codersdk/aiproviders.go:63 Stale doc: AIProviderSettings.Bedrock says "Only meaningful for AIProviderTypeAnthropic" R2 Gon P2, Hisoka P3, Mafuuu P3 Yes
CRF-8 P3 Open codersdk/deployment.go:4701 Stale doc: bedrock field comment says "only applicable when Type == anthropic" R2 Leorio P2, Mafuuu P3, Meruem Nit Yes
CRF-9 P3 Open codersdk/aibridge.go:178 Provider filter doc lists types (azure, bedrock, etc.) that never appear in stored provider column R2 Pariston P3 Yes
CRF-10 P3 Open cli/server.go:3010 Validation switches manually enumerate types; AIProviderType.Valid() and AllAIProviderTypeValues() exist R2 Ging-Go P3, Ryosuke P3 Yes
CRF-11 Nit Open cli/aibridged.go:240 Hardcoded "anthropic key pool" in merged case arm; OpenAI arm already uses row.Type R2 Chopper P3, Gon P3, Kite Nit, Mafuuu Nit Yes
CRF-12 Nit Open cli/server.go:3051 database.AIProviderType(p.Type) cast repeated 4 times in same loop body R2 Ryosuke Nit, Gon Nit Yes
CRF-13 Note Open (PR body) PR description body is empty; commit body reasoning lost on squash merge R2 Leorio P3 Yes

Contested and acknowledged

(none)

Round log

Round 1

Netero-only. 2 P2, 1 P3. Reviewed against 958c96b..42de9f5.

Round 2

Churn 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-review

CRF = Coder Review Finding (P0-P4, Nit, Note)

Reviewer Focus
Bisky tests
Chopper ops/errors
Churn-guard change verification
Ging language modernization
Gon naming
Hisoka edge cases
Killua perf
Kite change integrity
Knov contracts
Knuckle SQL
Kurapika security
Leorio docs
Luffy product
Mafu-san process
Mafuuu contracts
Melody dispatch/pairing
Meruem structural
Nami frontend
Netero mechanical checks
Pariston premise testing
Pen-botter product gaps
Razor verification
Robin duplication
Ryosuke Go arch
Takumi concurrency
Zoro shape

🤖 Managed by Coder Agents.

@dannykopping dannykopping changed the title feat(cli): route extra ai_provider_types through OpenAI and Anthropic providers feat: route extra ai_provider_types through OpenAI and Anthropic providers May 27, 2026
Copy link
Copy Markdown
Contributor

@coder-agents-review coder-agents-review Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread cli/server.go Outdated
Comment thread cli/aibridged.go
Comment thread coderd/ai_providers.go Outdated
@dannykopping dannykopping changed the base branch from dk/aibridge-hot-reload to graphite-base/25722 May 27, 2026 09:58
… 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.
@dannykopping dannykopping force-pushed the graphite-base/25722 branch from 958c96b to ae49249 Compare May 27, 2026 11:04
@dannykopping dannykopping force-pushed the dk/aibridge-providers-openai-compat branch from d3073ca to 2ba66c2 Compare May 27, 2026 11:04
@dannykopping dannykopping changed the base branch from graphite-base/25722 to main May 27, 2026 11:04
Copy link
Copy Markdown
Contributor Author

Addressed all three review findings in d3073ca:

  • CRF-1: Added three TYPE=bedrock test cases to TestReadAIProvidersFromEnv: BedrockTypeHappyPath, BedrockTypeWithoutBedrockFields, and BedrockTypeRejectsAPIKeys.
  • CRF-2: Added Bedrock entry to TestBuildAIProviderFromRowSetsAPIDumpDir with serialized Bedrock settings in the row.
  • CRF-3: Fixed stale doc comment on errAIProviderBedrockTypeMismatch to say "not anthropic- or bedrock-typed".

Copy link
Copy Markdown
Contributor Author

/coder-agents-review

Copy link
Copy Markdown
Contributor

@coder-agents-review coder-agents-review Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread codersdk/aiproviders.go
Comment thread cli/server_aibridge_internal_test.go
Comment thread cli/aibridged.go
Comment thread codersdk/aibridge.go Outdated
Comment thread cli/server.go Outdated
Comment thread cli/server.go Outdated
Comment thread codersdk/deployment.go
- 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
@dannykopping dannykopping requested a review from johnstcn May 27, 2026 12:04
@dannykopping dannykopping marked this pull request as ready for review May 27, 2026 12:04
- Use early-return pattern in ai_providers_migrate.go (revive lint)
- Remove extra blank line in mustMarshalSettings (revive lint)
@dannykopping dannykopping merged commit 2770bdc into main May 27, 2026
30 of 32 checks passed
@dannykopping dannykopping deleted the dk/aibridge-providers-openai-compat branch May 27, 2026 14:16
@github-actions github-actions Bot locked and limited conversation to collaborators May 27, 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.

3 participants