Repository navigation
feat(providers): reject unsupported provider×platform pairs (#1009) - #1025
Merged
Merged
Conversation
Closes the three fail-fast cells of the provider matrix — combinations
where the hyperscaler does not host the model vendor as a partner
endpoint. Previously these pairs would either 404 at the wire or
silently route traffic to the wrong URL with the wrong auth; now they
fail at provider construction with a clear, typed error.
Cells rejected:
- openai × vertex — Vertex AI does not host OpenAI as a partner
- gemini × bedrock — AWS Bedrock does not host Gemini
- gemini × azure — Azure AI Foundry does not host Gemini
Mechanism:
- New `UnsupportedProviderPlatformError{ProviderType, Platform}` in
runtime/providers/registry.go — sibling to the existing
`UnsupportedProviderError` for unknown provider types.
- New `RejectPlatforms(rejected, inner)` helper that wraps a
`ProviderFactory` and short-circuits with the typed error when
`spec.Platform` is in the rejected set. Reusable for future cells
we discover aren't offered.
- openai init() wraps its factory to reject `vertex`.
- gemini init() wraps its factory to reject `bedrock` and `azure`.
- Existing real pairs (openai+azure, gemini+vertex, claude+bedrock,
claude+vertex, plus the non-platform direct-API paths) fall through
`RejectPlatforms` unchanged.
Tests in reject_platforms_test.go cover:
- RejectPlatforms wrapper: rejects listed, allows unlisted+empty,
surfaces UnsupportedProviderPlatformError via errors.As.
- End-to-end CreateProviderFromSpec rejection for openai+vertex and
gemini+{bedrock,azure}.
Refs #1009
|
chaholl
added a commit
that referenced
this pull request
Apr 20, 2026
Adds the AWS Bedrock OpenAI-partner cell (gpt-oss family) to the provider matrix. 7th cell delivered against #1009 following: openai+azure (#1010), gemini+vertex (#1023), claude+vertex (#1024), fail-fast rejections (#1025). Wire format (verified against live Bedrock us-west-2): - URL: {baseURL}/model/{model-id}/invoke (standard Bedrock invoke) - Auth: AWS SigV4 via credentials.AWSCredential - Request: OpenAI Chat Completions JSON. Bedrock ignores the model field in the body (it routes by URL) so no stripping is needed — the existing request builder works as-is. - Response: standard OpenAI Chat Completions JSON — parsed by the existing openAIResponse unmarshal path. Code structure: - `bedrockPlatform` constant + `isBedrock()` predicate in openai.go. - `chatCompletionsURL()` and `responsesURL()` branch for Bedrock: the invoke URL path; Responses API falls back to Chat Completions (mirrors the existing Azure fallback — neither partner exposes it). - `NewProviderFromConfig` derives baseURL from PlatformConfig.Region via credentials.BedrockEndpoint when BaseURL is empty, forces APIModeCompletions, and auto-adds `max_tokens` and `top_p` to UnsupportedParams for the Bedrock default set: * max_tokens: gpt-oss requires `max_completion_tokens` instead (same switch the request builder already flips for o-series). * top_p: gpt-oss rejects 0.0 and the framework default is 0; omitting leaves the model default in place. Operators can override the full unsupported set via ProviderSpec.UnsupportedParams. - registry.go: api.openai.com/v1 default now skipped for Platform=="bedrock" as well as "azure", so the factory's PlatformConfig URL derivation is reachable (same root cause as #1010). Streaming (known limitation): Bedrock's `invoke-with-response-stream` returns binary event-stream framing with OpenAI-format chunks inside — distinct from the SSE the rest of the openai stream code expects. Until a dedicated scanner lands, PredictStream / PredictStreamWithTools run a non-streaming Predict and emit a single terminal StreamChunk with content + FinishReason + CostInfo. This is honest (Bedrock's plain `invoke` is non-streaming) and keeps Arena scenarios with `streaming: true` compatible. Tests: - bedrock_unit_test.go covers predicates, URL builders, factory URL derivation, API-mode forcing, unsupported-params auto-detection, and that explicit UnsupportedParams overrides Bedrock auto-detect. - bedrock_integration_test.go (//go:build integration) covers URL construction, predict, predict-with-tools, streaming fallback, error propagation, and cost calculation against a real Bedrock gpt-oss deployment. All 6 pass locally against us-west-2 on the omnia-aws profile. Refs #1009
chaholl
added a commit
that referenced
this pull request
Apr 20, 2026
* feat(providers): add openai bedrock code path (#1009 cell) Adds the AWS Bedrock OpenAI-partner cell (gpt-oss family) to the provider matrix. 7th cell delivered against #1009 following: openai+azure (#1010), gemini+vertex (#1023), claude+vertex (#1024), fail-fast rejections (#1025). Wire format (verified against live Bedrock us-west-2): - URL: {baseURL}/model/{model-id}/invoke (standard Bedrock invoke) - Auth: AWS SigV4 via credentials.AWSCredential - Request: OpenAI Chat Completions JSON. Bedrock ignores the model field in the body (it routes by URL) so no stripping is needed — the existing request builder works as-is. - Response: standard OpenAI Chat Completions JSON — parsed by the existing openAIResponse unmarshal path. Code structure: - `bedrockPlatform` constant + `isBedrock()` predicate in openai.go. - `chatCompletionsURL()` and `responsesURL()` branch for Bedrock: the invoke URL path; Responses API falls back to Chat Completions (mirrors the existing Azure fallback — neither partner exposes it). - `NewProviderFromConfig` derives baseURL from PlatformConfig.Region via credentials.BedrockEndpoint when BaseURL is empty, forces APIModeCompletions, and auto-adds `max_tokens` and `top_p` to UnsupportedParams for the Bedrock default set: * max_tokens: gpt-oss requires `max_completion_tokens` instead (same switch the request builder already flips for o-series). * top_p: gpt-oss rejects 0.0 and the framework default is 0; omitting leaves the model default in place. Operators can override the full unsupported set via ProviderSpec.UnsupportedParams. - registry.go: api.openai.com/v1 default now skipped for Platform=="bedrock" as well as "azure", so the factory's PlatformConfig URL derivation is reachable (same root cause as #1010). Streaming (known limitation): Bedrock's `invoke-with-response-stream` returns binary event-stream framing with OpenAI-format chunks inside — distinct from the SSE the rest of the openai stream code expects. Until a dedicated scanner lands, PredictStream / PredictStreamWithTools run a non-streaming Predict and emit a single terminal StreamChunk with content + FinishReason + CostInfo. This is honest (Bedrock's plain `invoke` is non-streaming) and keeps Arena scenarios with `streaming: true` compatible. Tests: - bedrock_unit_test.go covers predicates, URL builders, factory URL derivation, API-mode forcing, unsupported-params auto-detection, and that explicit UnsupportedParams overrides Bedrock auto-detect. - bedrock_integration_test.go (//go:build integration) covers URL construction, predict, predict-with-tools, streaming fallback, error propagation, and cost calculation against a real Bedrock gpt-oss deployment. All 6 pass locally against us-west-2 on the omnia-aws profile. Refs #1009 * test(providers): unit-test bedrock streaming fallbacks for SonarCloud coverage The bedrock_integration_test.go suite covers the new code path end-to-end against real AWS Bedrock, but build-tag `integration` is not run in CI so SonarCloud sees the predictStreamBedrockFallback and predictStreamWithToolsBedrockFallback bodies as uncovered (new_coverage 41.4% < 80% threshold). Adds httptest-based unit tests that mock the Bedrock invoke endpoint with canned OpenAI Chat Completions JSON and exercise: - PredictStream Bedrock path: emits exactly one terminal chunk with Content/Delta/FinishReason=stop/CostInfo populated. - PredictStream Bedrock error: 4xx upstream surfaces as error from the streaming entrypoint. - PredictStreamWithTools Bedrock path: emits exactly one terminal chunk with ToolCalls populated and FinishReason=tool_calls. - PredictStreamWithTools Bedrock error: 5xx upstream surfaces as error. No production code changes.
8 tasks done
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.



Summary
Closes three fail-fast cells of the provider matrix — combinations
where the hyperscaler does not host the model vendor as a partner
endpoint. These pairs previously would 404 at the wire or silently
route to the wrong URL with the wrong auth; they now fail at provider
construction with a typed, actionable error.
openai × vertexgemini × bedrockgemini × azureThis follows the three real-partner cells already landed —
openai+azure (#1010), gemini+vertex (#1023), claude+vertex (#1024) —
leaving 2 real cells still open in #1009 (claude+azure, openai+bedrock).
Mechanism
UnsupportedProviderPlatformError{ProviderType, Platform}inruntime/providers/registry.go, a sibling to the existingUnsupportedProviderErrorfor unknown provider types.RejectPlatforms(rejected, inner)helper that wraps aProviderFactoryand short-circuits with the typed error whenspec.Platformis in the rejected set. Reusable for future cells.init()wraps withRejectPlatforms{vertex}.init()wraps withRejectPlatforms{bedrock, azure}.claude+vertex, plus non-platform direct-API paths) fall through
RejectPlatformsunchanged.Tests
runtime/providers/reject_platforms_test.go:RejectPlatformswrapper — rejects listed, allows unlisted+empty,error surfaces through
errors.As(..., &UnsupportedProviderPlatformError).CreateProviderFromSpecrejection foropenai+vertexand
gemini+{bedrock,azure}.Pre-commit
gemini_tools.go 88.1% (all ≥80%)
Test plan
go test -race -count=1 ./runtime/providers/... ./runtime/providers/claude/... ./runtime/providers/openai/... ./runtime/providers/gemini/...— all greenMatrix status after this PR
Refs #1009