Merge pull request #3670 from code-yeongyu/fix/default-agent-config-key-normalization
fix(plugin-handlers): normalize default_agent config key before runtime-name lookup (fixes #3313)
This commit is contained in:
@@ -191,6 +191,56 @@ describe("applyAgentConfig builtin override protection", () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("normalizes display-name default_agent to runtime agent name", async () => {
|
||||||
|
// given
|
||||||
|
const config = createBaseConfig()
|
||||||
|
config.default_agent = "Sisyphus - Ultraworker"
|
||||||
|
|
||||||
|
// when
|
||||||
|
await applyAgentConfig({
|
||||||
|
config,
|
||||||
|
pluginConfig: createPluginConfig(),
|
||||||
|
ctx: { directory: "/tmp" },
|
||||||
|
pluginComponents: createPluginComponents(),
|
||||||
|
})
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(config.default_agent).toBe(getAgentRuntimeName("sisyphus"))
|
||||||
|
})
|
||||||
|
|
||||||
|
test("keeps config-key default_agent behavior unchanged", async () => {
|
||||||
|
// given
|
||||||
|
const config = createBaseConfig()
|
||||||
|
config.default_agent = "sisyphus"
|
||||||
|
|
||||||
|
// when
|
||||||
|
await applyAgentConfig({
|
||||||
|
config,
|
||||||
|
pluginConfig: createPluginConfig(),
|
||||||
|
ctx: { directory: "/tmp" },
|
||||||
|
pluginComponents: createPluginComponents(),
|
||||||
|
})
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(config.default_agent).toBe(getAgentRuntimeName("sisyphus"))
|
||||||
|
})
|
||||||
|
|
||||||
|
test("keeps fallback default_agent behavior unchanged", async () => {
|
||||||
|
// given
|
||||||
|
const config = createBaseConfig()
|
||||||
|
|
||||||
|
// when
|
||||||
|
await applyAgentConfig({
|
||||||
|
config,
|
||||||
|
pluginConfig: createPluginConfig(),
|
||||||
|
ctx: { directory: "/tmp" },
|
||||||
|
pluginComponents: createPluginComponents(),
|
||||||
|
})
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(config.default_agent).toBe(getAgentRuntimeName("sisyphus"))
|
||||||
|
})
|
||||||
|
|
||||||
test("filters user agents whose key matches the builtin display-name alias", async () => {
|
test("filters user agents whose key matches the builtin display-name alias", async () => {
|
||||||
// given
|
// given
|
||||||
loadUserAgentsSpy.mockReturnValue({
|
loadUserAgentsSpy.mockReturnValue({
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ import { createBuiltinAgents } from "../agents";
|
|||||||
import { createSisyphusJuniorAgentWithOverrides } from "../agents/sisyphus-junior";
|
import { createSisyphusJuniorAgentWithOverrides } from "../agents/sisyphus-junior";
|
||||||
import type { OhMyOpenCodeConfig } from "../config";
|
import type { OhMyOpenCodeConfig } from "../config";
|
||||||
import { isTaskSystemEnabled, log, migrateAgentConfig } from "../shared";
|
import { isTaskSystemEnabled, log, migrateAgentConfig } from "../shared";
|
||||||
import { getAgentRuntimeName } from "../shared/agent-display-names";
|
import {
|
||||||
|
getAgentConfigKey,
|
||||||
|
getAgentRuntimeName,
|
||||||
|
normalizeAgentForPromptKey,
|
||||||
|
} from "../shared/agent-display-names";
|
||||||
import { AGENT_NAME_MAP } from "../shared/migration";
|
import { AGENT_NAME_MAP } from "../shared/migration";
|
||||||
import { registerAgentName } from "../features/claude-code-session-state";
|
import { registerAgentName } from "../features/claude-code-session-state";
|
||||||
import {
|
import {
|
||||||
@@ -189,8 +193,10 @@ export async function applyAgentConfig(params: {
|
|||||||
|
|
||||||
if (isSisyphusEnabled && builtinAgents.sisyphus) {
|
if (isSisyphusEnabled && builtinAgents.sisyphus) {
|
||||||
if (configuredDefaultAgent) {
|
if (configuredDefaultAgent) {
|
||||||
|
const configKey = getAgentConfigKey(configuredDefaultAgent);
|
||||||
|
const runtimeConfigKey = normalizeAgentForPromptKey(configuredDefaultAgent) ?? configKey;
|
||||||
(params.config as { default_agent?: string }).default_agent =
|
(params.config as { default_agent?: string }).default_agent =
|
||||||
getAgentRuntimeName(configuredDefaultAgent);
|
getAgentRuntimeName(runtimeConfigKey);
|
||||||
} else {
|
} else {
|
||||||
(params.config as { default_agent?: string }).default_agent =
|
(params.config as { default_agent?: string }).default_agent =
|
||||||
getAgentRuntimeName("sisyphus");
|
getAgentRuntimeName("sisyphus");
|
||||||
|
|||||||
Reference in New Issue
Block a user