[fix]: Add bedrock to provider enum in Zod schemas and OpenAPI spec#1759
[fix]: Add bedrock to provider enum in Zod schemas and OpenAPI spec#1759
Conversation
Adds "bedrock" to the provider enum in ModelConfigObjectSchema and AgentConfigSchema, and regenerates the OpenAPI spec. This keeps the schemas in sync with the AISDK_PROVIDERS list (updated in #1604) and will propagate to generated SDKs (Python, Go, etc.) via Stainless. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 88e3372 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✱ Stainless preview buildsThis PR will update the ❗ stagehand-kotlin studio
✅ stagehand-typescript studio · code
✅ stagehand-go studio · code
✅ stagehand-ruby studio · code
✅ stagehand-python studio · code
✅ stagehand-java studio · code
✅ stagehand-php studio · code
|
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Greptile SummaryAdded Changes:
This ensures Python, Go, and other Stainless-generated SDKs will accept Confidence Score: 5/5
Important Files Changed
Last reviewed commit: c334542 |
The provider enum in the Zod schema now includes "bedrock", but the AgentType TypeScript type (used by ClientOptions.provider) didn't, causing a type mismatch in the server build. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 2 files
Confidence score: 3/5
- A hardcoded provider enum in
packages/core/lib/v3/types/public/api.tsis already out of sync withAISDK_PROVIDERS, which can lead to missing or rejected providers and user-facing behavior mismatches. - Severity is moderate (7/10) with high confidence, so there’s some regression risk if new providers are added or existing ones differ.
- Pay close attention to
packages/core/lib/v3/types/public/api.ts- hardcoded provider list may drift fromAISDK_PROVIDERS.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/core/lib/v3/types/public/api.ts">
<violation number="1" location="packages/core/lib/v3/types/public/api.ts:55">
P1: Custom agent: **Ensure we never check against hardcoded lists of allowed LLM model names**
This hardcoded provider enum is already out of sync with `AISDK_PROVIDERS` (5 vs 14 providers) and will need yet another update for every new provider. Per our guideline against hardcoded allowed-lists, consider switching to `z.string()` here so that validation is left to the LLM provider at runtime. The `modelName` field already accepts a free-form `provider/model-name` string, making this enum redundant as a guardrail. If enum values are needed for SDK documentation/hints, they could be expressed as OpenAPI `examples` rather than a restrictive `enum`.
Alternatively, if the enum must stay for SDK generation reasons, at minimum derive it from the canonical `AISDK_PROVIDERS` array in `packages/server/src/types/model.ts` to keep a single source of truth.</violation>
</file>
Architecture diagram
sequenceDiagram
participant Dev as Developer / CI
participant Zod as Core Zod Schemas
participant Spec as OpenAPI Spec (YAML)
participant Stainless as Stainless (External)
participant SDK as Generated SDKs (Py/Go)
participant API as Server Runtime
Note over Dev, SDK: Build & Code Generation Flow
Dev->>Zod: NEW: Add "bedrock" to provider enum
Dev->>Spec: CHANGED: Run pnpm gen:openapi
Zod-->>Spec: Export updated schemas
Spec->>Stainless: Ingest updated OpenAPI YAML
Stainless-->>SDK: NEW: Regenerate SDKs with "bedrock" literal types
Note over SDK, API: Runtime Request Flow
rect rgb(23, 37, 84)
Note right of SDK: Client Application Usage
SDK->>SDK: NEW: Allow "bedrock" in type-safe config
SDK->>API: POST /request (provider: "bedrock")
end
API->>Zod: Validate request payload
alt Valid Provider ("bedrock" or existing)
Zod-->>API: NEW: Validation Success
API->>API: Resolve LLM Provider Logic
Note right of API: Handled by existing Bedrock integration
else Invalid Provider
Zod-->>API: 400 Bad Request
end
API-->>SDK: Response
SDK-->>Dev: Data
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| .object({ | ||
| provider: z | ||
| .enum(["openai", "anthropic", "google", "microsoft"]) | ||
| .enum(["openai", "anthropic", "google", "microsoft", "bedrock"]) |
There was a problem hiding this comment.
P1: Custom agent: Ensure we never check against hardcoded lists of allowed LLM model names
This hardcoded provider enum is already out of sync with AISDK_PROVIDERS (5 vs 14 providers) and will need yet another update for every new provider. Per our guideline against hardcoded allowed-lists, consider switching to z.string() here so that validation is left to the LLM provider at runtime. The modelName field already accepts a free-form provider/model-name string, making this enum redundant as a guardrail. If enum values are needed for SDK documentation/hints, they could be expressed as OpenAPI examples rather than a restrictive enum.
Alternatively, if the enum must stay for SDK generation reasons, at minimum derive it from the canonical AISDK_PROVIDERS array in packages/server/src/types/model.ts to keep a single source of truth.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/core/lib/v3/types/public/api.ts, line 55:
<comment>This hardcoded provider enum is already out of sync with `AISDK_PROVIDERS` (5 vs 14 providers) and will need yet another update for every new provider. Per our guideline against hardcoded allowed-lists, consider switching to `z.string()` here so that validation is left to the LLM provider at runtime. The `modelName` field already accepts a free-form `provider/model-name` string, making this enum redundant as a guardrail. If enum values are needed for SDK documentation/hints, they could be expressed as OpenAPI `examples` rather than a restrictive `enum`.
Alternatively, if the enum must stay for SDK generation reasons, at minimum derive it from the canonical `AISDK_PROVIDERS` array in `packages/server/src/types/model.ts` to keep a single source of truth.</comment>
<file context>
@@ -52,7 +52,7 @@ export const LocalBrowserLaunchOptionsSchema = z
.object({
provider: z
- .enum(["openai", "anthropic", "google", "microsoft"])
+ .enum(["openai", "anthropic", "google", "microsoft", "bedrock"])
.optional()
.meta({
</file context>
There was a problem hiding this comment.
ok to ignore for now, but we should fix this someday
There was a problem hiding this comment.
Thanks for the update—I'll treat this as non-blocking for now.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
"bedrock"to theproviderenum inModelConfigObjectSchemaandAgentConfigSchema(Zod schemas inpackages/core/lib/v3/types/public/api.ts)packages/server/openapi.v3.yamlviapnpm gen:openapiContext
Bedrock was added to
AISDK_PROVIDERSandLLMProviderin PRs #1604 and #1617, but the Zod schemas that feed the OpenAPI spec (and ultimately the Stainless-generated SDKs) were never updated. This means the Python/Go/etc. SDK type definitions don't include"bedrock"as a valid provider option.Companion PR in bb/core: https://github.com/browserbase/core/pull/7668
Test plan
pnpm gen:openapiproduces updated spec withbedrockin all 4 provider enum locationsbedrockin theproviderliteral type🤖 Generated with Claude Code
Summary by cubic
Add "bedrock" to provider enums in ModelConfigObjectSchema/AgentConfigSchema and regenerate the OpenAPI spec so SDKs accept it and stay in sync with AISDK_PROVIDERS/LLMProvider. Also update AgentType to include "bedrock" to fix a server build type mismatch, and add a patch changeset to publish and unblock Python/Go SDK type generation.
Written for commit 88e3372. Summary will update on new commits. Review in cubic