Merge pull request #1849 from jkoelker/preserve-default-agent

fix(config): preserve configured default_agent
This commit is contained in:
YeonGyu-Kim 2026-02-17 01:43:04 +09:00 committed by GitHub
commit 0e0bfc1cd6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 58 additions and 1 deletions

View File

@ -23,6 +23,11 @@ type AgentConfigRecord = Record<string, Record<string, unknown> | undefined> & {
plan?: Record<string, unknown>;
};
function hasConfiguredDefaultAgent(config: Record<string, unknown>): boolean {
const defaultAgent = config.default_agent;
return typeof defaultAgent === "string" && defaultAgent.trim().length > 0;
}
export async function applyAgentConfig(params: {
config: Record<string, unknown>;
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<string, unknown> = {
sisyphus: builtinAgents.sisyphus,

View File

@ -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<string, unknown> = {
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<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
expect(config.default_agent).toBe(getAgentDisplayName("sisyphus"))
})
})
describe("Prometheus category config resolution", () => {
test("resolves ultrabrain category config", () => {
// given