diff --git a/src/plugin-handlers/agent-config-handler.ts b/src/plugin-handlers/agent-config-handler.ts index 101300a61..91cbf2a96 100644 --- a/src/plugin-handlers/agent-config-handler.ts +++ b/src/plugin-handlers/agent-config-handler.ts @@ -23,6 +23,11 @@ type AgentConfigRecord = Record | undefined> & { plan?: Record; }; +function hasConfiguredDefaultAgent(config: Record): boolean { + const defaultAgent = config.default_agent; + return typeof defaultAgent === "string" && defaultAgent.trim().length > 0; +} + export async function applyAgentConfig(params: { config: Record; pluginConfig: OhMyOpenCodeConfig; @@ -106,7 +111,10 @@ export async function applyAgentConfig(params: { const configAgent = params.config.agent as AgentConfigRecord | undefined; if (isSisyphusEnabled && builtinAgents.sisyphus) { - (params.config as { default_agent?: string }).default_agent = getAgentDisplayName("sisyphus"); + if (!hasConfiguredDefaultAgent(params.config)) { + (params.config as { default_agent?: string }).default_agent = + getAgentDisplayName("sisyphus"); + } const agentConfig: Record = { sisyphus: builtinAgents.sisyphus, diff --git a/src/plugin-handlers/config-handler.test.ts b/src/plugin-handlers/config-handler.test.ts index cf6e2461b..c8e25f588 100644 --- a/src/plugin-handlers/config-handler.test.ts +++ b/src/plugin-handlers/config-handler.test.ts @@ -349,6 +349,55 @@ describe("Agent permission defaults", () => { }) }) +describe("default_agent behavior with Sisyphus orchestration", () => { + test("preserves existing default_agent when already set", async () => { + // #given + const pluginConfig: OhMyOpenCodeConfig = {} + const config: Record = { + model: "anthropic/claude-opus-4-6", + default_agent: "hephaestus", + agent: {}, + } + const handler = createConfigHandler({ + ctx: { directory: "/tmp" }, + pluginConfig, + modelCacheState: { + anthropicContext1MEnabled: false, + modelContextLimitsCache: new Map(), + }, + }) + + // #when + await handler(config) + + // #then + expect(config.default_agent).toBe("hephaestus") + }) + + test("sets default_agent to sisyphus when missing", async () => { + // #given + const pluginConfig: OhMyOpenCodeConfig = {} + const config: Record = { + model: "anthropic/claude-opus-4-6", + agent: {}, + } + const handler = createConfigHandler({ + ctx: { directory: "/tmp" }, + pluginConfig, + modelCacheState: { + anthropicContext1MEnabled: false, + modelContextLimitsCache: new Map(), + }, + }) + + // #when + await handler(config) + + // #then + expect(config.default_agent).toBe(getAgentDisplayName("sisyphus")) + }) +}) + describe("Prometheus category config resolution", () => { test("resolves ultrabrain category config", () => { // given