fix(plugin-handlers): normalize default agent runtime lookup
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
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 () => {
|
||||
// given
|
||||
loadUserAgentsSpy.mockReturnValue({
|
||||
|
||||
@@ -2,7 +2,11 @@ import { createBuiltinAgents } from "../agents";
|
||||
import { createSisyphusJuniorAgentWithOverrides } from "../agents/sisyphus-junior";
|
||||
import type { OhMyOpenCodeConfig } from "../config";
|
||||
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 { registerAgentName } from "../features/claude-code-session-state";
|
||||
import {
|
||||
@@ -189,8 +193,10 @@ export async function applyAgentConfig(params: {
|
||||
|
||||
if (isSisyphusEnabled && builtinAgents.sisyphus) {
|
||||
if (configuredDefaultAgent) {
|
||||
const configKey = getAgentConfigKey(configuredDefaultAgent);
|
||||
const runtimeConfigKey = normalizeAgentForPromptKey(configuredDefaultAgent) ?? configKey;
|
||||
(params.config as { default_agent?: string }).default_agent =
|
||||
getAgentRuntimeName(configuredDefaultAgent);
|
||||
getAgentRuntimeName(runtimeConfigKey);
|
||||
} else {
|
||||
(params.config as { default_agent?: string }).default_agent =
|
||||
getAgentRuntimeName("sisyphus");
|
||||
|
||||
Reference in New Issue
Block a user