From b1f43e81131bd62a6174c249f1137ca3efbaf487 Mon Sep 17 00:00:00 2001 From: ismeth Date: Thu, 12 Feb 2026 14:14:33 +0100 Subject: [PATCH] test(04-01): add Athena registration and schema regressions - verify Athena primary agents honor uiSelectedModel and override precedence - add schema tests to lock athena acceptance in builtin and overridable names --- src/agents/utils.test.ts | 66 ++++++++++++++++++++++++++- src/config/schema/agent-names.test.ts | 26 +++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 src/config/schema/agent-names.test.ts diff --git a/src/agents/utils.test.ts b/src/agents/utils.test.ts index 2feb71216..dbcfb7d91 100644 --- a/src/agents/utils.test.ts +++ b/src/agents/utils.test.ts @@ -147,6 +147,69 @@ describe("createBuiltinAgents with model overrides", () => { } }) + test("Athena uses uiSelectedModel when provided", async () => { + // #given + const fetchSpy = spyOn(shared, "fetchAvailableModels").mockResolvedValue( + new Set(["openai/gpt-5.2", "anthropic/claude-opus-4-6"]) + ) + const uiSelectedModel = "openai/gpt-5.2" + + try { + // #when + const agents = await createBuiltinAgents( + [], + {}, + undefined, + TEST_DEFAULT_MODEL, + undefined, + undefined, + [], + undefined, + undefined, + uiSelectedModel + ) + + // #then + expect(agents.athena).toBeDefined() + expect(agents.athena.model).toBe("openai/gpt-5.2") + } finally { + fetchSpy.mockRestore() + } + }) + + test("user config model takes priority over uiSelectedModel for athena", async () => { + // #given + const fetchSpy = spyOn(shared, "fetchAvailableModels").mockResolvedValue( + new Set(["openai/gpt-5.2", "anthropic/claude-opus-4-6"]) + ) + const uiSelectedModel = "openai/gpt-5.2" + const overrides = { + athena: { model: "anthropic/claude-opus-4-6" }, + } + + try { + // #when + const agents = await createBuiltinAgents( + [], + overrides, + undefined, + TEST_DEFAULT_MODEL, + undefined, + undefined, + [], + undefined, + undefined, + uiSelectedModel + ) + + // #then + expect(agents.athena).toBeDefined() + expect(agents.athena.model).toBe("anthropic/claude-opus-4-6") + } finally { + fetchSpy.mockRestore() + } + }) + test("Sisyphus is created on first run when no availableModels or cache exist", async () => { // #given const systemDefaultModel = "anthropic/claude-opus-4-6" @@ -428,7 +491,8 @@ describe("createBuiltinAgents with model overrides", () => { ) // #then - const matches = (agents.sisyphus?.prompt ?? "").match(/Custom agent: researcher/gi) ?? [] + expect(agents.sisyphus.prompt).toBeDefined() + const matches = (agents.sisyphus.prompt ?? "").match(/Custom agent: researcher/gi) ?? [] expect(matches.length).toBe(1) } finally { fetchSpy.mockRestore() diff --git a/src/config/schema/agent-names.test.ts b/src/config/schema/agent-names.test.ts new file mode 100644 index 000000000..28e9efd23 --- /dev/null +++ b/src/config/schema/agent-names.test.ts @@ -0,0 +1,26 @@ +import { describe, expect, test } from "bun:test" +import { BuiltinAgentNameSchema, OverridableAgentNameSchema } from "./agent-names" + +describe("agent name schemas", () => { + test("BuiltinAgentNameSchema accepts athena", () => { + //#given + const candidate = "athena" + + //#when + const result = BuiltinAgentNameSchema.safeParse(candidate) + + //#then + expect(result.success).toBe(true) + }) + + test("OverridableAgentNameSchema accepts athena", () => { + //#given + const candidate = "athena" + + //#when + const result = OverridableAgentNameSchema.safeParse(candidate) + + //#then + expect(result.success).toBe(true) + }) +})