From 961ce19415d42e60fd9cab280d378034c82e5173 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 2 Feb 2026 11:22:32 +0900 Subject: [PATCH] feat(cli): deny Question tool in CLI run mode In CLI run mode there is no TUI to answer questions, so the Question tool would hang forever. This sets OPENCODE_CLI_RUN_MODE env var in runner.ts and config-handler uses it to set question permission to deny for sisyphus, hephaestus, and prometheus agents. --- src/cli/run/runner.ts | 4 ++++ src/plugin-handlers/config-handler.ts | 10 +++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/cli/run/runner.ts b/src/cli/run/runner.ts index 0fe6b819..a9bc7b12 100644 --- a/src/cli/run/runner.ts +++ b/src/cli/run/runner.ts @@ -77,6 +77,10 @@ export const resolveRunAgent = ( } export async function run(options: RunOptions): Promise { + // Set CLI run mode environment variable before any config loading + // This signals to config-handler to deny Question tool (no TUI to answer) + process.env.OPENCODE_CLI_RUN_MODE = "true" + const { message, directory = process.cwd(), diff --git a/src/plugin-handlers/config-handler.ts b/src/plugin-handlers/config-handler.ts index b21ec1d1..49e85c58 100644 --- a/src/plugin-handlers/config-handler.ts +++ b/src/plugin-handlers/config-handler.ts @@ -409,6 +409,10 @@ export function createConfigHandler(deps: ConfigHandlerDeps) { }; type AgentWithPermission = { permission?: Record }; + + // In CLI run mode, deny Question tool for all agents (no TUI to answer questions) + const isCliRunMode = process.env.OPENCODE_CLI_RUN_MODE === "true"; + const questionPermission = isCliRunMode ? "deny" : "allow"; if (agentResult.librarian) { const agent = agentResult.librarian as AgentWithPermission; @@ -424,15 +428,15 @@ export function createConfigHandler(deps: ConfigHandlerDeps) { } if (agentResult.sisyphus) { const agent = agentResult.sisyphus as AgentWithPermission; - agent.permission = { ...agent.permission, call_omo_agent: "deny", delegate_task: "allow", question: "allow", "task_*": "allow", teammate: "allow" }; + agent.permission = { ...agent.permission, call_omo_agent: "deny", delegate_task: "allow", question: questionPermission, "task_*": "allow", teammate: "allow" }; } if (agentResult.hephaestus) { const agent = agentResult.hephaestus as AgentWithPermission; - agent.permission = { ...agent.permission, call_omo_agent: "deny", delegate_task: "allow", question: "allow" }; + agent.permission = { ...agent.permission, call_omo_agent: "deny", delegate_task: "allow", question: questionPermission }; } if (agentResult["prometheus"]) { const agent = agentResult["prometheus"] as AgentWithPermission; - agent.permission = { ...agent.permission, call_omo_agent: "deny", delegate_task: "allow", question: "allow", "task_*": "allow", teammate: "allow" }; + agent.permission = { ...agent.permission, call_omo_agent: "deny", delegate_task: "allow", question: questionPermission, "task_*": "allow", teammate: "allow" }; } if (agentResult["sisyphus-junior"]) { const agent = agentResult["sisyphus-junior"] as AgentWithPermission;