task: review and document agent selection

This commit is contained in:
YeonGyu-Kim
2026-03-16 14:30:59 +09:00
parent c073169949
commit 40f25fb07d
4 changed files with 52 additions and 5 deletions
+4 -3
View File
@@ -94,9 +94,10 @@ Examples:
Agent resolution order:
1) --agent flag
2) OPENCODE_DEFAULT_AGENT
3) oh-my-opencode.json "default_run_agent"
4) Sisyphus (fallback)
2) OPENCODE_AGENT
3) OPENCODE_DEFAULT_AGENT
4) oh-my-opencode.json "default_run_agent"
5) Sisyphus (fallback)
Available core agents:
Sisyphus, Hephaestus, Prometheus, Atlas
+4 -1
View File
@@ -5,6 +5,7 @@ import { getAgentConfigKey, getAgentDisplayName } from "../../shared/agent-displ
const CORE_AGENT_ORDER = ["sisyphus", "hephaestus", "prometheus", "atlas"] as const
const DEFAULT_AGENT = "sisyphus"
const ENV_AGENT_KEYS = ["OPENCODE_AGENT", "OPENCODE_DEFAULT_AGENT"] as const
type EnvVars = Record<string, string | undefined>
type CoreAgentKey = (typeof CORE_AGENT_ORDER)[number]
@@ -54,7 +55,9 @@ export const resolveRunAgent = (
env: EnvVars = process.env
): string => {
const cliAgent = normalizeAgentName(options.agent)
const envAgent = normalizeAgentName(env.OPENCODE_DEFAULT_AGENT)
const envAgent = ENV_AGENT_KEYS
.map((key) => normalizeAgentName(env[key]))
.find((agent) => agent !== undefined)
const configAgent = normalizeAgentName(pluginConfig.default_run_agent)
const resolved =
cliAgent ??
+43
View File
@@ -37,6 +37,38 @@ describe("resolveRunAgent", () => {
expect(agent).toBe("Atlas (Plan Executor)")
})
it("prefers OPENCODE_AGENT over OPENCODE_DEFAULT_AGENT", () => {
// given
const config = createConfig({ default_run_agent: "prometheus" })
const env = {
OPENCODE_AGENT: "oracle",
OPENCODE_DEFAULT_AGENT: "Atlas",
}
// when
const agent = resolveRunAgent({ message: "test" }, config, env)
// then
expect(agent).toBe("oracle")
})
it("supports specialist agents from env and config inputs", () => {
// given
const env = { OPENCODE_AGENT: " explore " }
// when
const envAgent = resolveRunAgent({ message: "test" }, createConfig(), env)
const configAgent = resolveRunAgent(
{ message: "test" },
createConfig({ default_run_agent: "oracle" }),
{}
)
// then
expect(envAgent).toBe("explore")
expect(configAgent).toBe("oracle")
})
it("uses config agent over default", () => {
// given
const config = createConfig({ default_run_agent: "Prometheus" })
@@ -80,6 +112,17 @@ describe("resolveRunAgent", () => {
// then
expect(agent).toBe("Sisyphus (Ultraworker)")
})
it("falls back when requested specialist agent is disabled", () => {
// given
const config = createConfig({ disabled_agents: ["oracle"] })
// when
const agent = resolveRunAgent({ message: "test", agent: "oracle" }, config, {})
// then
expect(agent).toBe("Sisyphus (Ultraworker)")
})
})
describe("waitForEventProcessorShutdown", () => {
+1 -1
View File
@@ -25,7 +25,7 @@ export const OhMyOpenCodeConfigSchema = z.object({
$schema: z.string().optional(),
/** Enable new task system (default: false) */
new_task_system_enabled: z.boolean().optional(),
/** Default agent name for `oh-my-opencode run` (env: OPENCODE_DEFAULT_AGENT) */
/** Default agent name for `oh-my-opencode run` (env fallback: OPENCODE_DEFAULT_AGENT, after OPENCODE_AGENT) */
default_run_agent: z.string().optional(),
disabled_mcps: z.array(AnyMcpNameSchema).optional(),
disabled_agents: z.array(z.string()).optional(),