Repository navigation
fix(providers): hyperscaler routing — openai+azure (#1010), gemini+vertex (#1009 cell) - #1023
Merged
Merged
Conversation
The provider registry defaulted spec.BaseURL to https://api.openai.com/v1 whenever spec.Type=="openai" and spec.BaseURL=="" — without checking spec.Platform. This clobbered the empty BaseURL that the openai factory's Azure branch (NewProviderFromConfig) relies on to construct the deployment URL from PlatformConfig, making the Azure path unreachable. Net effect pre-fix: a Provider configured with type:openai + platform.type:azure resolved Entra credentials correctly, then sent the request to api.openai.com and 401'd with invalid_issuer. Skip the openai default specifically when spec.Platform=="azure" so the factory's existing Azure URL builder runs. Adds a regression test (TestCreateProviderFromSpecOpenAIAzureSkipsDefault) and an integration suite (azure_integration_test.go) that exercises the full path against a real Azure AI Foundry deployment. Fixes #1010
The gemini provider hard-coded the Google AI Studio URL shape
({baseURL}/models/{model}:generateContent?key={apiKey}) and never called
its credential — so a Provider configured with platform.type:vertex
resolved a GCP credential then sent the request to the wrong URL with
the wrong auth scheme.
Add the Vertex code path with minimum surface area:
- vertexPlatform constant + isVertex() predicate
- vertexGeminiEndpoint(region, project) builds the publisher-models URL
- generateContentURL(action) branches Vertex vs AI Studio shape:
Vertex: {baseURL}/{model}:{action} (no /models/, no key)
AI Studio: {baseURL}/models/{model}:{action}?key={k} (unchanged)
- applyAuth(ctx, req) calls credential.Apply for Vertex (Bearer token);
no-op for AI Studio (key is in the URL)
- NewProviderWithCredential derives the Vertex URL from PlatformConfig
when caller passes empty BaseURL — mirrors the openai+azure pattern,
so Arena configs that only set platform.region/project work without
the user knowing the Vertex URL shape
All six URL build sites in gemini.go, gemini_tools.go, gemini_multimodal.go,
and gemini_streaming.go now route through the helpers. registry.go skips
the AI Studio default for Platform=vertex (same #1010 root cause as
openai+azure).
Adds vertex_integration_test.go covering URL construction, auth shape,
predict, predict-with-tools, streaming, error propagation, and cost
calculation against a real Vertex deployment.
Refs #1009
Three minimal Arena configs that exercise each cloud cell end-to-end — provider config + 3 scenarios (text, streaming, tool calling) + 1 mock tool. Each example is independently runnable once the matching cloud credentials are available locally. - examples/azure-foundry-test openai+azure (covers the #1010 path) - examples/bedrock-test claude+bedrock - examples/vertex-test gemini+vertex (covers the new #1009 cell) Endpoints/projects in the YAMLs are concrete (Altaira demo resources). Adapt three strings — provider endpoint, region/project — to point at your own cloud account. Auth comes from the local CLI cache for each cloud (az login / AWS_PROFILE / gcloud ADC); no env-var keys needed. Run: cd examples/azure-foundry-test PROMPTKIT_SCHEMA_SOURCE=local ../../bin/promptarena run --ci --formats html,json These complement the unit-level integration tests added in the previous commits — same code paths, but exercised through the full Arena pipeline (config loading, registry, provider factory, tool registry, SSE streaming, assertions, cost accounting).
The integration tests added in 4f7a... and d657434 only run against real cloud endpoints; they don't execute under SonarCloud's coverage analysis. SonarCloud flagged new_coverage at 68.1% (under the 80% gate) because the Vertex branches in gemini.go and the registry skip for gemini+vertex weren't exercised by any unit test. Adds: - runtime/providers/gemini/vertex_unit_test.go: - vertexGeminiEndpoint URL composition - isVertex() across all platform values - generateContentURL() Vertex vs AI Studio URL shape (incl. stream) - applyAuth() bearer-token attachment vs no-op for AI Studio - NewProviderWithCredential URL derivation, including: explicit URL wins, incomplete PlatformConfig leaves URL empty, non-vertex platform doesn't trigger derivation - runtime/providers/registry_extended_test.go: regression test mirroring the openai+azure one, asserting the AI Studio default doesn't clobber spec.BaseURL when Platform=="vertex" No production code changes.
|
chaholl
added a commit
that referenced
this pull request
Apr 20, 2026
Adds the Vertex AI Anthropic-partner cell to the provider matrix. Mirrors the openai+azure (#1010) and gemini+vertex (#1023) patterns: the per-provider factory derives the platform URL from PlatformConfig when caller passes an empty BaseURL, and the registry skips the vendor default for that platform pair so the factory branch is reachable. Vertex Anthropic specifics handled: - URL: {baseURL}/{model}:rawPredict for Predict / PredictWithTools, {baseURL}/{model}:streamRawPredict for the streaming variants. - Body: shared partner shape (no `model`, no `stream`, `anthropic_version` body key) with the platform-specific value `vertex-2023-10-16` (vs Bedrock's `bedrock-2023-05-31`). - Auth: Bearer token via the GCP credential chain (the same credential.Apply path Bedrock already uses for SigV4 — neither partner uses x-api-key). - Streaming transport: SSE (NewSSEScanner), distinct from Bedrock's binary event-stream (NewBedrockEventScanner). Both wired through RunStreamingRequest for retry / budget / semaphore parity. - Errors: routed through providers.ParsePlatformHTTPError so the Vertex error envelope is parsed instead of returned as raw bytes. Code structure: - `vertexPlatform`, `vertexVersionValue`, `vertexAnthropicEndpoint` in claude.go. - `isVertex()`, `isPartnerHosted()`, `platformAnthropicVersion()` predicates so callers branch by capability rather than enumerating platforms inline. - `messagesURL()` / `messagesStreamURL()` extended with a Vertex branch. - `marshalBedrockRequest` and `marshalBedrockStreamingRequest` generalized: same body shape, version sourced from `platformAnthropicVersion()` so they serve both Bedrock and Vertex. - `applyToolRequestHeaders` and `makeRequest` switched from `isBedrock` to `isPartnerHosted` for body-modification and auth dispatch. Tool-streaming gains a `streamVertexToolRequest` peer to the existing Bedrock and direct-API helpers; the SSE wiring is factored into `runSSEToolStream` so direct and Vertex paths share the engine and only differ in body bytes. - Registry skips `https://api.anthropic.com` default when `spec.Platform=="vertex"` (regression test added). The Bedrock path is unchanged — the existing Bedrock integration test still passes after the refactor. Tests: - `vertex_unit_test.go` covers helpers (predicates, URL builders, body marshallers) and the factory URL derivation. - `vertex_streaming_test.go` uses httptest to drive PredictStream through the new Vertex branch and asserts wire format (`:streamRawPredict` URL action, no `model`/`stream` in body, `anthropic_version=vertex-2023-10-16`, Bearer auth, no x-api-key, no anthropic-version header). - `registry_extended_test.go` adds the claude+vertex regression test matching the openai+azure and gemini+vertex ones. Refs #1009
chaholl
added a commit
that referenced
this pull request
Apr 20, 2026
Mirrors the gemini+vertex (#1023) and bedrock integration suites: build-tag `integration`, env-gated skips when GCP_PROJECT is unset or ADC tokens are unavailable. Covers URL derivation, predict, predict-with-tools, streaming, error propagation, and cost calculation against a real Vertex Anthropic-partner deployment. Live runs additionally require Anthropic models to be enabled in the project's Vertex Model Garden (a manual one-time terms-acceptance in the GCP console, analogous to the Bedrock use-case form). Without that step the tests propagate Vertex's standard 404 "Publisher Model not found or your project does not have access" which the new ParsePlatformHTTPError integration in claude.go surfaces cleanly. Run: gcloud auth application-default login gcloud auth application-default set-quota-project <project> export GCP_PROJECT=<project> go test -tags=integration ./runtime/providers/claude/... -run Vertex -v
4 tasks done
chaholl
added a commit
that referenced
this pull request
Apr 20, 2026
* feat(providers): add claude vertex code path (#1009 cell) Adds the Vertex AI Anthropic-partner cell to the provider matrix. Mirrors the openai+azure (#1010) and gemini+vertex (#1023) patterns: the per-provider factory derives the platform URL from PlatformConfig when caller passes an empty BaseURL, and the registry skips the vendor default for that platform pair so the factory branch is reachable. Vertex Anthropic specifics handled: - URL: {baseURL}/{model}:rawPredict for Predict / PredictWithTools, {baseURL}/{model}:streamRawPredict for the streaming variants. - Body: shared partner shape (no `model`, no `stream`, `anthropic_version` body key) with the platform-specific value `vertex-2023-10-16` (vs Bedrock's `bedrock-2023-05-31`). - Auth: Bearer token via the GCP credential chain (the same credential.Apply path Bedrock already uses for SigV4 — neither partner uses x-api-key). - Streaming transport: SSE (NewSSEScanner), distinct from Bedrock's binary event-stream (NewBedrockEventScanner). Both wired through RunStreamingRequest for retry / budget / semaphore parity. - Errors: routed through providers.ParsePlatformHTTPError so the Vertex error envelope is parsed instead of returned as raw bytes. Code structure: - `vertexPlatform`, `vertexVersionValue`, `vertexAnthropicEndpoint` in claude.go. - `isVertex()`, `isPartnerHosted()`, `platformAnthropicVersion()` predicates so callers branch by capability rather than enumerating platforms inline. - `messagesURL()` / `messagesStreamURL()` extended with a Vertex branch. - `marshalBedrockRequest` and `marshalBedrockStreamingRequest` generalized: same body shape, version sourced from `platformAnthropicVersion()` so they serve both Bedrock and Vertex. - `applyToolRequestHeaders` and `makeRequest` switched from `isBedrock` to `isPartnerHosted` for body-modification and auth dispatch. Tool-streaming gains a `streamVertexToolRequest` peer to the existing Bedrock and direct-API helpers; the SSE wiring is factored into `runSSEToolStream` so direct and Vertex paths share the engine and only differ in body bytes. - Registry skips `https://api.anthropic.com` default when `spec.Platform=="vertex"` (regression test added). The Bedrock path is unchanged — the existing Bedrock integration test still passes after the refactor. Tests: - `vertex_unit_test.go` covers helpers (predicates, URL builders, body marshallers) and the factory URL derivation. - `vertex_streaming_test.go` uses httptest to drive PredictStream through the new Vertex branch and asserts wire format (`:streamRawPredict` URL action, no `model`/`stream` in body, `anthropic_version=vertex-2023-10-16`, Bearer auth, no x-api-key, no anthropic-version header). - `registry_extended_test.go` adds the claude+vertex regression test matching the openai+azure and gemini+vertex ones. Refs #1009 * test(providers): add claude vertex integration test Mirrors the gemini+vertex (#1023) and bedrock integration suites: build-tag `integration`, env-gated skips when GCP_PROJECT is unset or ADC tokens are unavailable. Covers URL derivation, predict, predict-with-tools, streaming, error propagation, and cost calculation against a real Vertex Anthropic-partner deployment. Live runs additionally require Anthropic models to be enabled in the project's Vertex Model Garden (a manual one-time terms-acceptance in the GCP console, analogous to the Bedrock use-case form). Without that step the tests propagate Vertex's standard 404 "Publisher Model not found or your project does not have access" which the new ParsePlatformHTTPError integration in claude.go surfaces cleanly. Run: gcloud auth application-default login gcloud auth application-default set-quota-project <project> export GCP_PROJECT=<project> go test -tags=integration ./runtime/providers/claude/... -run Vertex -v
3 tasks done
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 the openai+azure routing bug (#1010) and adds the missing
gemini+vertex code path (one cell of #1009). Both fixes share the same
root cause: the provider registry's vendor-default-baseURL switch
clobbered the empty
spec.BaseURLthat per-provider factories rely onto derive platform-specific URLs.
End-to-end verified locally — all three hyperscaler cells now route
correctly through both the unit-integration tests and the full Arena
pipeline.
What changed
fix(providers): unblock openai+azure routing (#1010)runtime/providers/registry.go— skip thehttps://api.openai.com/v1default when
spec.Platform=="azure"so the openai factory's existingAzure URL builder (
NewProviderFromConfig) becomes reachable.runtime/providers/registry_extended_test.go— regression testasserting
BaseURLstays empty for openai+azure.runtime/providers/openai/azure_integration_test.go— 7 build-tagintegrationtests covering URL construction, predict, tools,streaming, error path, cost.
feat(providers): add gemini vertex code path (#1009 cell)runtime/providers/gemini/gemini.go— addsvertexPlatform,vertexGeminiEndpoint,isVertex(),generateContentURL(action),applyAuth().NewProviderWithCredentialderives the Vertex URLfrom
PlatformConfigwhen caller passes emptyBaseURL, mirroringthe openai+azure pattern.
runtime/providers/gemini/{gemini,gemini_tools,gemini_multimodal,gemini_streaming}.go— all six URL build sites switched to
generateContentURL; all sixrequest paths now call
applyAuth(Bearer token for Vertex, no-opfor AI Studio).
runtime/providers/registry.go— skip the AI Studio default whenspec.Platform=="vertex"(same root cause as openai+azure).runtime/providers/gemini/vertex_integration_test.go— 7 testsmirroring the Azure suite.
docs(examples): add hyperscaler smoke-test arena examplesThree minimal Arena examples that exercise each cell end-to-end:
examples/azure-foundry-test,examples/bedrock-test,examples/vertex-test. Each ships a provider config + 3 scenarios(text, streaming, tool calling) + 1 mock tool.
Authentication
No PromptKit changes for credentials — each cloud uses its native
SDK's default chain, which transparently picks up either local CLI
caches (
az login/~/.aws/credentials/gcloud auth application-default login) or CI-side workload identity federation(
azure/login@v2/aws-actions/configure-aws-credentials@v4/google-github-actions/auth@v2). Same code path; the chain justselects a different element.
Pre-commit
All three commits passed the local pre-commit hook:
gemini_multimodal.go 82.4%, gemini_streaming.go 93.4%,
gemini_tools.go 88.1% (all ≥80% threshold)
Test plan
go test -race -count=1 ./runtime/providers/...— all packages greengo test -tags=integration -run ^TestAzure_ ./runtime/providers/openai/— 7/7 pass against Azure AI Foundrygo test -tags=integration -run ^TestBedrock_ ./runtime/providers/claude/— 5/5 pass against AWS Bedrockgo test -tags=integration -run ^TestVertex_ ./runtime/providers/gemini/— 7/7 pass against GCP Vertexpromptarena run --ci --formats html,jsonin each example dir — 3/3 scenarios pass per cloudOut of scope
capability-matrix.yml— requires per-cloud OIDC + IAM setup separately.Fixes #1010
Refs #1009