fix(schema): preserve custom agent overrides via catchall

AgentOverridesSchema silently strips custom agent keys during Zod
parsing because only 14 built-in names are explicitly defined. Add
.catchall(AgentOverrideConfigSchema.optional()) so user-defined agent
configs survive validation and reach downstream consumers like
resolveModelAndFallbackChain().

Fixes #3229.
This commit is contained in:
mrosnerr
2026-04-30 17:08:06 -04:00
parent f8b22e1f76
commit bcc554bb6e
2 changed files with 39 additions and 1 deletions
+38
View File
@@ -0,0 +1,38 @@
import { describe, expect, test } from "bun:test"
import { AgentOverridesSchema } from "./agent-overrides"
describe("AgentOverridesSchema", () => {
test("preserves custom agent keys after parsing", () => {
const input = {
sisyphus: { model: "anthropic/claude-opus-4-6" },
"technical-writer": {
model: "anthropic/claude-sonnet-4-6",
temperature: 0.3,
prompt_append: "You are a technical writer.",
},
}
const result = AgentOverridesSchema.safeParse(input)
expect(result.success).toBe(true)
if (result.success) {
expect(result.data.sisyphus).toBeDefined()
expect(result.data["technical-writer"]).toBeDefined()
expect(result.data["technical-writer"]?.model).toBe("anthropic/claude-sonnet-4-6")
expect(result.data["technical-writer"]?.temperature).toBe(0.3)
}
})
test("validates custom agent keys against AgentOverrideConfigSchema", () => {
const input = {
"custom-agent": {
model: "provider/model",
temperature: 5, // invalid: max is 2
},
}
const result = AgentOverridesSchema.safeParse(input)
expect(result.success).toBe(false)
})
})
+1 -1
View File
@@ -72,7 +72,7 @@ export const AgentOverridesSchema = z.object({
explore: AgentOverrideConfigSchema.optional(),
"multimodal-looker": AgentOverrideConfigSchema.optional(),
atlas: AgentOverrideConfigSchema.optional(),
})
}).catchall(AgentOverrideConfigSchema.optional())
export type AgentOverrideConfig = z.infer<typeof AgentOverrideConfigSchema>
export type AgentOverrides = z.infer<typeof AgentOverridesSchema>