Skip to content

Commit c51397b

Browse files
committed
fix(dashboard-agent): treat empty model provider as unset, fix Sonnet Bedrock id
DASHBOARD_AGENT_MODEL_PROVIDER="" rejected boot instead of falling back to the default. BEDROCK_MODEL_IDS mapped Sonnet 4.6 to a nonexistent -v1 suffix; Anthropic's official table has no -v1 for Sonnet. Pin exact ids in the test rather than a shape regex.
1 parent c8cdea6 commit c51397b

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

apps/webapp/app/env.server.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,10 @@ const EnvironmentSchema = z
211211
ANTHROPIC_API_KEY: z.string().optional(),
212212
// Selects the dashboard agent's LLM provider (default anthropic). The internal
213213
// seam reads process.env directly; this entry validates the value webapp-side.
214-
DASHBOARD_AGENT_MODEL_PROVIDER: z.enum(["anthropic", "bedrock"]).default("anthropic"),
214+
DASHBOARD_AGENT_MODEL_PROVIDER: z.preprocess(
215+
(v) => (typeof v === "string" && v.trim() === "" ? undefined : v),
216+
z.enum(["anthropic", "bedrock"]).default("anthropic")
217+
),
215218
// AWS credentials for the dashboard agent's Bedrock provider (only used when
216219
// DASHBOARD_AGENT_MODEL_PROVIDER=bedrock; default path stays Anthropic). The
217220
// provider resolves credentials itself, so only the region is read here.

internal-packages/dashboard-agent/src/model-provider.test.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe("resolveDashboardAgentModel", () => {
4949
it("maps the same canonical string to a Bedrock inference profile", () => {
5050
useBedrock();
5151
expect(resolveDashboardAgentModel("anthropic:claude-sonnet-4-6").modelId).toBe(
52-
"us.anthropic.claude-sonnet-4-6-v1"
52+
"us.anthropic.claude-sonnet-4-6"
5353
);
5454
expect(resolveDashboardAgentModel("anthropic:claude-haiku-4-5").modelId).toBe(
5555
"us.anthropic.claude-haiku-4-5-20251001-v1:0"
@@ -63,16 +63,13 @@ describe("resolveDashboardAgentModel", () => {
6363
);
6464
});
6565

66-
// Structural, not an echo of the table: an AWS us cross-region Anthropic profile
67-
// is either dated with a `:N` suffix, or an undated `-vN` (the 4-6 generation). A
68-
// dated id must never drop its `:N`, and every id must end in a version.
69-
it("every Bedrock-mapped id has a well-formed AWS inference-profile shape", () => {
70-
const dated = /^us\.anthropic\.claude-[a-z]+(?:-\d+)+-\d{8}-v\d+:\d+$/;
71-
const undated = /^us\.anthropic\.claude-[a-z]+(?:-\d+)+-v\d+$/;
72-
for (const id of Object.values(BEDROCK_MODEL_IDS)) {
73-
expect(dated.test(id) || undated.test(id), id).toBe(true);
74-
if (/-\d{8}-/.test(id)) expect(id, id).toMatch(/:\d+$/);
75-
}
66+
// Pinned to Anthropic's official Bedrock model table, not a shape regex — there is
67+
// no shared suffix convention across models, so a well-formed id can still be wrong.
68+
it("maps every model to its exact documented Bedrock id", () => {
69+
expect(BEDROCK_MODEL_IDS).toEqual({
70+
"claude-sonnet-4-6": "us.anthropic.claude-sonnet-4-6",
71+
"claude-haiku-4-5": "us.anthropic.claude-haiku-4-5-20251001-v1:0",
72+
});
7673
});
7774
});
7875

internal-packages/dashboard-agent/src/model-provider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ export const registry = createProviderRegistry({ anthropic, bedrock });
5454

5555
/**
5656
* Canonical model id -> Bedrock us cross-region inference profile, verbatim from
57-
* the @ai-sdk/amazon-bedrock model-id union. The 4-6 generation profiles are
58-
* undated `-vN`; 4-5 and older carry a date and a `:N` suffix.
57+
* Anthropic's official Bedrock model table. No shared suffix convention across
58+
* models — copy each id exactly rather than deriving it.
5959
*/
6060
export const BEDROCK_MODEL_IDS: Record<string, string> = {
61-
"claude-sonnet-4-6": "us.anthropic.claude-sonnet-4-6-v1",
61+
"claude-sonnet-4-6": "us.anthropic.claude-sonnet-4-6",
6262
"claude-haiku-4-5": "us.anthropic.claude-haiku-4-5-20251001-v1:0",
6363
};
6464

0 commit comments

Comments
 (0)