fix(config): prevent plan agent from inheriting prometheus prompt on demote
Plan agent demote now only sets mode to 'subagent' without spreading prometheus config. This ensures plan agent uses OpenCode's default prompt instead of inheriting prometheus prompt.
This commit is contained in:
parent
bf87bf473f
commit
f030992755
@ -145,8 +145,8 @@ describe("Plan agent demote behavior", () => {
|
|||||||
expect(ordered).toEqual(coreAgents)
|
expect(ordered).toEqual(coreAgents)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("plan agent should be demoted to subagent mode when replacePlan is true", async () => {
|
test("plan agent should be demoted to subagent without inheriting prometheus prompt", async () => {
|
||||||
// given
|
// #given
|
||||||
const pluginConfig: OhMyOpenCodeConfig = {
|
const pluginConfig: OhMyOpenCodeConfig = {
|
||||||
sisyphus_agent: {
|
sisyphus_agent: {
|
||||||
planner_enabled: true,
|
planner_enabled: true,
|
||||||
@ -172,62 +172,22 @@ describe("Plan agent demote behavior", () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
// when
|
// #when
|
||||||
await handler(config)
|
await handler(config)
|
||||||
|
|
||||||
// then
|
// #then - plan is demoted to subagent but does NOT inherit prometheus prompt
|
||||||
const agents = config.agent as Record<string, { mode?: string; name?: string; prompt?: string }>
|
const agents = config.agent as Record<string, { mode?: string; name?: string; prompt?: string }>
|
||||||
expect(agents.plan).toBeDefined()
|
expect(agents.plan).toBeDefined()
|
||||||
expect(agents.plan.mode).toBe("subagent")
|
expect(agents.plan.mode).toBe("subagent")
|
||||||
expect(agents.plan.name).toBe("plan")
|
expect(agents.plan.prompt).toBeUndefined()
|
||||||
expect(agents.plan.prompt).toBe("original plan prompt")
|
expect(agents.prometheus?.prompt).toBeDefined()
|
||||||
expect(agents.plan.prompt).not.toBe(agents.prometheus?.prompt)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test("plan agent should not be demoted when replacePlan is false", async () => {
|
test("plan agent remains unchanged when planner is disabled", async () => {
|
||||||
// given
|
// #given
|
||||||
const pluginConfig: OhMyOpenCodeConfig = {
|
|
||||||
sisyphus_agent: {
|
|
||||||
planner_enabled: true,
|
|
||||||
replace_plan: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
const config: Record<string, unknown> = {
|
|
||||||
model: "anthropic/claude-opus-4-5",
|
|
||||||
agent: {
|
|
||||||
plan: {
|
|
||||||
name: "plan",
|
|
||||||
mode: "primary",
|
|
||||||
prompt: "original plan prompt",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
const handler = createConfigHandler({
|
|
||||||
ctx: { directory: "/tmp" },
|
|
||||||
pluginConfig,
|
|
||||||
modelCacheState: {
|
|
||||||
anthropicContext1MEnabled: false,
|
|
||||||
modelContextLimitsCache: new Map(),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
// when
|
|
||||||
await handler(config)
|
|
||||||
|
|
||||||
// then
|
|
||||||
const agents = config.agent as Record<string, { mode?: string; name?: string; prompt?: string }>
|
|
||||||
expect(agents.plan).toBeDefined()
|
|
||||||
expect(agents.plan.mode).toBe("primary")
|
|
||||||
expect(agents.plan.name).toBe("plan")
|
|
||||||
expect(agents.plan.prompt).toBe("original plan prompt")
|
|
||||||
})
|
|
||||||
|
|
||||||
test("plan agent should not be demoted when planner is disabled", async () => {
|
|
||||||
// given
|
|
||||||
const pluginConfig: OhMyOpenCodeConfig = {
|
const pluginConfig: OhMyOpenCodeConfig = {
|
||||||
sisyphus_agent: {
|
sisyphus_agent: {
|
||||||
planner_enabled: false,
|
planner_enabled: false,
|
||||||
replace_plan: true,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
const config: Record<string, unknown> = {
|
const config: Record<string, unknown> = {
|
||||||
@ -249,50 +209,15 @@ describe("Plan agent demote behavior", () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
// when
|
// #when
|
||||||
await handler(config)
|
await handler(config)
|
||||||
|
|
||||||
// then
|
// #then - plan is not touched, prometheus is not created
|
||||||
const agents = config.agent as Record<string, { mode?: string; name?: string; prompt?: string }>
|
const agents = config.agent as Record<string, { mode?: string; name?: string; prompt?: string }>
|
||||||
expect(agents.prometheus).toBeUndefined()
|
expect(agents.prometheus).toBeUndefined()
|
||||||
expect(agents.plan).toBeDefined()
|
expect(agents.plan).toBeDefined()
|
||||||
expect(agents.plan.mode).toBe("primary")
|
expect(agents.plan.mode).toBe("primary")
|
||||||
})
|
expect(agents.plan.prompt).toBe("original plan prompt")
|
||||||
|
|
||||||
test("preserves empty plan prompt when demoting", async () => {
|
|
||||||
// given
|
|
||||||
const pluginConfig: OhMyOpenCodeConfig = {
|
|
||||||
sisyphus_agent: {
|
|
||||||
planner_enabled: true,
|
|
||||||
replace_plan: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
const config: Record<string, unknown> = {
|
|
||||||
model: "anthropic/claude-opus-4-5",
|
|
||||||
agent: {
|
|
||||||
plan: {
|
|
||||||
name: "plan",
|
|
||||||
mode: "primary",
|
|
||||||
prompt: "",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
const handler = createConfigHandler({
|
|
||||||
ctx: { directory: "/tmp" },
|
|
||||||
pluginConfig,
|
|
||||||
modelCacheState: {
|
|
||||||
anthropicContext1MEnabled: false,
|
|
||||||
modelContextLimitsCache: new Map(),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
// when
|
|
||||||
await handler(config)
|
|
||||||
|
|
||||||
// then
|
|
||||||
const agents = config.agent as Record<string, { prompt?: string }>
|
|
||||||
expect(agents.plan).toBeDefined()
|
|
||||||
expect(agents.plan.prompt).toBe("")
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test("prometheus should have mode 'all' to be callable via delegate_task", async () => {
|
test("prometheus should have mode 'all' to be callable via delegate_task", async () => {
|
||||||
|
|||||||
@ -195,7 +195,7 @@ export function createConfigHandler(deps: ConfigHandlerDeps) {
|
|||||||
const plannerEnabled =
|
const plannerEnabled =
|
||||||
pluginConfig.sisyphus_agent?.planner_enabled ?? true;
|
pluginConfig.sisyphus_agent?.planner_enabled ?? true;
|
||||||
const replacePlan = pluginConfig.sisyphus_agent?.replace_plan ?? true;
|
const replacePlan = pluginConfig.sisyphus_agent?.replace_plan ?? true;
|
||||||
const shouldReplacePlan = plannerEnabled && replacePlan;
|
const shouldDemotePlan = plannerEnabled && replacePlan;
|
||||||
|
|
||||||
type AgentConfig = Record<
|
type AgentConfig = Record<
|
||||||
string,
|
string,
|
||||||
@ -211,12 +211,6 @@ export function createConfigHandler(deps: ConfigHandlerDeps) {
|
|||||||
};
|
};
|
||||||
const configAgent = config.agent as AgentConfig | undefined;
|
const configAgent = config.agent as AgentConfig | undefined;
|
||||||
|
|
||||||
const { name: _planName, mode: _planMode, ...planConfigWithoutName } =
|
|
||||||
configAgent?.plan ?? {};
|
|
||||||
const planPrompt = (migrateAgentConfig(
|
|
||||||
planConfigWithoutName as Record<string, unknown>
|
|
||||||
) as { prompt?: string }).prompt;
|
|
||||||
|
|
||||||
if (isSisyphusEnabled && builtinAgents.sisyphus) {
|
if (isSisyphusEnabled && builtinAgents.sisyphus) {
|
||||||
(config as { default_agent?: string }).default_agent = "sisyphus";
|
(config as { default_agent?: string }).default_agent = "sisyphus";
|
||||||
|
|
||||||
@ -345,7 +339,7 @@ export function createConfigHandler(deps: ConfigHandlerDeps) {
|
|||||||
Object.entries(configAgent)
|
Object.entries(configAgent)
|
||||||
.filter(([key]) => {
|
.filter(([key]) => {
|
||||||
if (key === "build") return false;
|
if (key === "build") return false;
|
||||||
if (key === "plan" && shouldReplacePlan) return false;
|
if (key === "plan" && shouldDemotePlan) return false;
|
||||||
// Filter out agents that oh-my-opencode provides to prevent
|
// Filter out agents that oh-my-opencode provides to prevent
|
||||||
// OpenCode defaults from overwriting user config in oh-my-opencode.json
|
// OpenCode defaults from overwriting user config in oh-my-opencode.json
|
||||||
// See: https://github.com/code-yeongyu/oh-my-opencode/issues/472
|
// See: https://github.com/code-yeongyu/oh-my-opencode/issues/472
|
||||||
@ -363,13 +357,8 @@ export function createConfigHandler(deps: ConfigHandlerDeps) {
|
|||||||
? migrateAgentConfig(configAgent.build as Record<string, unknown>)
|
? migrateAgentConfig(configAgent.build as Record<string, unknown>)
|
||||||
: {};
|
: {};
|
||||||
|
|
||||||
const planDemoteConfig = shouldReplacePlan && agentConfig["prometheus"]
|
const planDemoteConfig = shouldDemotePlan
|
||||||
? {
|
? { mode: "subagent" as const }
|
||||||
...agentConfig["prometheus"],
|
|
||||||
name: "plan",
|
|
||||||
mode: "subagent" as const,
|
|
||||||
...(typeof planPrompt === "string" ? { prompt: planPrompt } : {}),
|
|
||||||
}
|
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
config.agent = {
|
config.agent = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user