fix(custom-agents): preserve summary flags during description merge
This commit is contained in:
parent
754a2593f9
commit
fb139a7a01
@ -351,6 +351,68 @@ describe("custom agent overrides", () => {
|
|||||||
expect(agentsConfig[pKey].prompt).toContain("translator")
|
expect(agentsConfig[pKey].prompt).toContain("translator")
|
||||||
expect(agentsConfig[pKey].prompt).not.toContain("ghostwriter")
|
expect(agentsConfig[pKey].prompt).not.toContain("ghostwriter")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("custom agent summary merge preserves flags when custom_agents adds description", async () => {
|
||||||
|
// #given
|
||||||
|
;(agentLoader.loadUserAgents as any).mockReturnValue({
|
||||||
|
translator: {
|
||||||
|
name: "translator",
|
||||||
|
mode: "subagent",
|
||||||
|
description: "",
|
||||||
|
hidden: true,
|
||||||
|
disabled: true,
|
||||||
|
enabled: false,
|
||||||
|
prompt: "Translate content",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const createBuiltinAgentsMock = agents.createBuiltinAgents as unknown as {
|
||||||
|
mock: { calls: unknown[][] }
|
||||||
|
}
|
||||||
|
|
||||||
|
const pluginConfig: OhMyOpenCodeConfig = {
|
||||||
|
custom_agents: {
|
||||||
|
translator: {
|
||||||
|
description: "Translate and localize locale files",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
sisyphus_agent: {
|
||||||
|
planner_enabled: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
const config: Record<string, unknown> = {
|
||||||
|
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
|
||||||
|
const firstCallArgs = createBuiltinAgentsMock.mock.calls[0]
|
||||||
|
const summaries = firstCallArgs[7] as Array<{
|
||||||
|
name: string
|
||||||
|
description: string
|
||||||
|
hidden?: boolean
|
||||||
|
disabled?: boolean
|
||||||
|
enabled?: boolean
|
||||||
|
}>
|
||||||
|
const translatorSummary = summaries.find((summary) => summary.name === "translator")
|
||||||
|
|
||||||
|
expect(translatorSummary).toBeDefined()
|
||||||
|
expect(translatorSummary?.description).toBe("Translate and localize locale files")
|
||||||
|
expect(translatorSummary?.hidden).toBe(true)
|
||||||
|
expect(translatorSummary?.disabled).toBe(true)
|
||||||
|
expect(translatorSummary?.enabled).toBe(false)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("Plan agent demote behavior", () => {
|
describe("Plan agent demote behavior", () => {
|
||||||
|
|||||||
@ -74,9 +74,9 @@ export function collectCustomAgentSummariesFromRecord(
|
|||||||
summaries.push({
|
summaries.push({
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
hidden: agentValue.hidden === true,
|
hidden: typeof agentValue.hidden === "boolean" ? agentValue.hidden : undefined,
|
||||||
disabled: agentValue.disabled === true,
|
disabled: typeof agentValue.disabled === "boolean" ? agentValue.disabled : undefined,
|
||||||
enabled: agentValue.enabled === false ? false : true,
|
enabled: typeof agentValue.enabled === "boolean" ? agentValue.enabled : undefined,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,9 +99,15 @@ export function mergeCustomAgentSummaries(...summaryGroups: AgentSummary[][]): A
|
|||||||
|
|
||||||
const existingDescription = existing.description.trim();
|
const existingDescription = existing.description.trim();
|
||||||
const incomingDescription = summary.description.trim();
|
const incomingDescription = summary.description.trim();
|
||||||
if (!existingDescription && incomingDescription) {
|
|
||||||
merged.set(key, summary);
|
merged.set(key, {
|
||||||
}
|
...existing,
|
||||||
|
...summary,
|
||||||
|
hidden: summary.hidden ?? existing.hidden,
|
||||||
|
disabled: summary.disabled ?? existing.disabled,
|
||||||
|
enabled: summary.enabled ?? existing.enabled,
|
||||||
|
description: incomingDescription || existingDescription,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user