fix(sisyphus-agent): prevent duplicate build/plan agents when replacement enabled
- Filter out original 'build' and 'plan' agents when Builder-Sisyphus/Planner-Sisyphus are enabled with replacement - Previously both agents could coexist even with replace_build/replace_plan: true - Now only the replacement agent exists when both enabled and replacement flags are true - Maintains backward compatibility for all configuration combinations Fixes #231
This commit is contained in:
17
src/index.ts
17
src/index.ts
@@ -426,14 +426,25 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
|||||||
: plannerSisyphusBase;
|
: plannerSisyphusBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filter out build/plan from config.agent if they will be replaced
|
||||||
|
const filteredConfigAgents = config.agent ?
|
||||||
|
Object.fromEntries(
|
||||||
|
Object.entries(config.agent).filter(([key]) => {
|
||||||
|
if (key === "build" && builderEnabled && replaceBuild) return false;
|
||||||
|
if (key === "plan" && plannerEnabled && replacePlan) return false;
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
) : {};
|
||||||
|
|
||||||
config.agent = {
|
config.agent = {
|
||||||
...agentConfig,
|
...agentConfig,
|
||||||
...Object.fromEntries(Object.entries(builtinAgents).filter(([k]) => k !== "Sisyphus")),
|
...Object.fromEntries(Object.entries(builtinAgents).filter(([k]) => k !== "Sisyphus")),
|
||||||
...userAgents,
|
...userAgents,
|
||||||
...projectAgents,
|
...projectAgents,
|
||||||
...config.agent,
|
...filteredConfigAgents, // Filtered config agents (excludes build/plan if replaced)
|
||||||
...(replaceBuild ? { build: { ...config.agent?.build, mode: "subagent" } } : {}),
|
// Only set to subagent mode if NOT being replaced (for backward compatibility)
|
||||||
...(replacePlan ? { plan: { ...config.agent?.plan, mode: "subagent" } } : {}),
|
...(replaceBuild && !builderEnabled ? { build: { ...config.agent?.build, mode: "subagent" } } : {}),
|
||||||
|
...(replacePlan && !plannerEnabled ? { plan: { ...config.agent?.plan, mode: "subagent" } } : {}),
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
config.agent = {
|
config.agent = {
|
||||||
|
|||||||
Reference in New Issue
Block a user