fix(config): scope default_agent normalization to Sisyphus mode
This commit is contained in:
parent
a562e3aa4b
commit
a2ad7ce6a7
@ -112,15 +112,13 @@ export async function applyAgentConfig(params: {
|
|||||||
const shouldDemotePlan = plannerEnabled && replacePlan;
|
const shouldDemotePlan = plannerEnabled && replacePlan;
|
||||||
const configuredDefaultAgent = getConfiguredDefaultAgent(params.config);
|
const configuredDefaultAgent = getConfiguredDefaultAgent(params.config);
|
||||||
|
|
||||||
if (configuredDefaultAgent) {
|
|
||||||
(params.config as { default_agent?: string }).default_agent =
|
|
||||||
getAgentDisplayName(configuredDefaultAgent);
|
|
||||||
}
|
|
||||||
|
|
||||||
const configAgent = params.config.agent as AgentConfigRecord | undefined;
|
const configAgent = params.config.agent as AgentConfigRecord | undefined;
|
||||||
|
|
||||||
if (isSisyphusEnabled && builtinAgents.sisyphus) {
|
if (isSisyphusEnabled && builtinAgents.sisyphus) {
|
||||||
if (!configuredDefaultAgent) {
|
if (configuredDefaultAgent) {
|
||||||
|
(params.config as { default_agent?: string }).default_agent =
|
||||||
|
getAgentDisplayName(configuredDefaultAgent);
|
||||||
|
} else {
|
||||||
(params.config as { default_agent?: string }).default_agent =
|
(params.config as { default_agent?: string }).default_agent =
|
||||||
getAgentDisplayName("sisyphus");
|
getAgentDisplayName("sisyphus");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -350,6 +350,54 @@ describe("Agent permission defaults", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe("default_agent behavior with Sisyphus orchestration", () => {
|
describe("default_agent behavior with Sisyphus orchestration", () => {
|
||||||
|
test("canonicalizes configured default_agent with surrounding whitespace", 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(getAgentDisplayName("hephaestus"))
|
||||||
|
})
|
||||||
|
|
||||||
|
test("canonicalizes configured default_agent when key uses mixed case", 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(getAgentDisplayName("hephaestus"))
|
||||||
|
})
|
||||||
|
|
||||||
test("canonicalizes configured default_agent key to display name", async () => {
|
test("canonicalizes configured default_agent key to display name", async () => {
|
||||||
// #given
|
// #given
|
||||||
const pluginConfig: OhMyOpenCodeConfig = {}
|
const pluginConfig: OhMyOpenCodeConfig = {}
|
||||||
@ -421,6 +469,82 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
|
|||||||
// #then
|
// #then
|
||||||
expect(config.default_agent).toBe(getAgentDisplayName("sisyphus"))
|
expect(config.default_agent).toBe(getAgentDisplayName("sisyphus"))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("sets default_agent to sisyphus when configured default_agent is empty after trim", async () => {
|
||||||
|
// given
|
||||||
|
const pluginConfig: OhMyOpenCodeConfig = {}
|
||||||
|
const config: Record<string, unknown> = {
|
||||||
|
model: "anthropic/claude-opus-4-6",
|
||||||
|
default_agent: " ",
|
||||||
|
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"))
|
||||||
|
})
|
||||||
|
|
||||||
|
test("preserves custom default_agent names while trimming whitespace", async () => {
|
||||||
|
// given
|
||||||
|
const pluginConfig: OhMyOpenCodeConfig = {}
|
||||||
|
const config: Record<string, unknown> = {
|
||||||
|
model: "anthropic/claude-opus-4-6",
|
||||||
|
default_agent: " Custom Agent ",
|
||||||
|
agent: {},
|
||||||
|
}
|
||||||
|
const handler = createConfigHandler({
|
||||||
|
ctx: { directory: "/tmp" },
|
||||||
|
pluginConfig,
|
||||||
|
modelCacheState: {
|
||||||
|
anthropicContext1MEnabled: false,
|
||||||
|
modelContextLimitsCache: new Map(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
// when
|
||||||
|
await handler(config)
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(config.default_agent).toBe("Custom Agent")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("does not normalize configured default_agent when Sisyphus is disabled", async () => {
|
||||||
|
// given
|
||||||
|
const pluginConfig: OhMyOpenCodeConfig = {
|
||||||
|
sisyphus_agent: {
|
||||||
|
disabled: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
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 ")
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("Prometheus category config resolution", () => {
|
describe("Prometheus category config resolution", () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user