fix(cli): use getAgentRuntimeName for agent resolution in run command

This commit is contained in:
YeonGyu-Kim
2026-04-15 14:46:50 +09:00
parent 81a03fa9d0
commit 47aa3025db
2 changed files with 18 additions and 15 deletions
+10 -8
View File
@@ -1,7 +1,7 @@
import pc from "picocolors"
import type { RunOptions } from "./types"
import type { OhMyOpenCodeConfig } from "../../config"
import { getAgentConfigKey, getAgentDisplayName } from "../../shared/agent-display-names"
import { getAgentConfigKey, getAgentDisplayName, getAgentRuntimeName } from "../../shared/agent-display-names"
const CORE_AGENT_ORDER = ["sisyphus", "hephaestus", "prometheus", "atlas"] as const
const DEFAULT_AGENT = "sisyphus"
@@ -21,11 +21,12 @@ const normalizeAgentName = (agent?: string): ResolvedAgent | undefined => {
const configKey = getAgentConfigKey(trimmed)
const displayName = getAgentDisplayName(configKey)
const runtimeName = getAgentRuntimeName(configKey)
const isKnownAgent = displayName !== configKey
return {
configKey,
resolvedName: isKnownAgent ? displayName : trimmed,
resolvedName: isKnownAgent ? runtimeName : trimmed,
}
}
@@ -61,27 +62,28 @@ export const resolveRunAgent = (
envAgent ??
configAgent ?? {
configKey: DEFAULT_AGENT,
resolvedName: getAgentDisplayName(DEFAULT_AGENT),
resolvedName: getAgentRuntimeName(DEFAULT_AGENT),
}
if (isAgentDisabled(resolved.configKey, pluginConfig)) {
const fallback = pickFallbackAgent(pluginConfig)
const fallbackName = getAgentDisplayName(fallback)
const fallbackDisplayName = getAgentDisplayName(fallback)
const fallbackRuntimeName = getAgentRuntimeName(fallback)
const fallbackDisabled = isAgentDisabled(fallback, pluginConfig)
if (fallbackDisabled) {
console.log(
pc.yellow(
`Requested agent "${resolved.resolvedName}" is disabled and no enabled core agent was found. Proceeding with "${fallbackName}".`
`Requested agent "${resolved.resolvedName}" is disabled and no enabled core agent was found. Proceeding with "${fallbackDisplayName}".`
)
)
return fallbackName
return fallbackRuntimeName
}
console.log(
pc.yellow(
`Requested agent "${resolved.resolvedName}" is disabled. Falling back to "${fallbackName}".`
`Requested agent "${resolved.resolvedName}" is disabled. Falling back to "${fallbackDisplayName}".`
)
)
return fallbackName
return fallbackRuntimeName
}
return resolved.resolvedName
+8 -7
View File
@@ -3,6 +3,7 @@
import { afterEach, beforeEach, describe, expect, it, spyOn } from "bun:test"
import { OhMyOpenCodeConfigSchema, type OhMyOpenCodeConfig } from "../../config"
import { resolveRunAgent } from "./agent-resolver"
import { getAgentRuntimeName } from "../../shared/agent-display-names"
const createConfig = (overrides: Partial<OhMyOpenCodeConfig> = {}): OhMyOpenCodeConfig =>
OhMyOpenCodeConfigSchema.parse(overrides)
@@ -31,7 +32,7 @@ describe("resolveRunAgent", () => {
)
// then
expect(agent).toBe("Hephaestus - Deep Agent")
expect(agent).toBe(getAgentRuntimeName("hephaestus"))
})
it("uses env agent over config", () => {
@@ -43,7 +44,7 @@ describe("resolveRunAgent", () => {
const agent = resolveRunAgent({ message: "test" }, config, env)
// then
expect(agent).toBe("Atlas - Plan Executor")
expect(agent).toBe(getAgentRuntimeName("atlas"))
})
it("uses config agent over default", () => {
@@ -54,7 +55,7 @@ describe("resolveRunAgent", () => {
const agent = resolveRunAgent({ message: "test" }, config, {})
// then
expect(agent).toBe("Prometheus - Plan Builder")
expect(agent).toBe(getAgentRuntimeName("prometheus"))
})
it("falls back to sisyphus when none set", () => {
@@ -65,7 +66,7 @@ describe("resolveRunAgent", () => {
const agent = resolveRunAgent({ message: "test" }, config, {})
// then
expect(agent).toBe("Sisyphus - Ultraworker")
expect(agent).toBe(getAgentRuntimeName("sisyphus"))
})
it("skips disabled sisyphus for next available core agent", () => {
@@ -76,10 +77,10 @@ describe("resolveRunAgent", () => {
const agent = resolveRunAgent({ message: "test" }, config, {})
// then
expect(agent).toBe("Hephaestus - Deep Agent")
expect(agent).toBe(getAgentRuntimeName("hephaestus"))
})
it("maps display-name style default_run_agent values to canonical display names", () => {
it("maps display-name style default_run_agent values to canonical runtime names", () => {
// given
const config = createConfig({ default_run_agent: "Sisyphus - Ultraworker" })
@@ -87,7 +88,7 @@ describe("resolveRunAgent", () => {
const agent = resolveRunAgent({ message: "test" }, config, {})
// then
expect(agent).toBe("Sisyphus - Ultraworker")
expect(agent).toBe(getAgentRuntimeName("sisyphus"))
})
})