From e6a0faed9a068e8393ca396451aaac5830d1a8ba Mon Sep 17 00:00:00 2001 From: Pedram Amini Date: Mon, 2 Feb 2026 22:33:24 -0600 Subject: [PATCH] fix(opencode): disable question tool to prevent batch mode hangs The OpenCode question tool waits for stdin input when invoked, which causes Maestro to hang indefinitely in batch mode (Auto Run) since stdin is closed immediately after the prompt is sent. Added `"tools":{"question":false}` to the OPENCODE_CONFIG_CONTENT environment variable to disable the question tool. This forces the agent to communicate questions via normal text output instead. Root cause analysis from user debug logs: - Auto Run batch session ran for ~10 minutes without any output - Process had to be killed manually (0/20 tasks completed) - OpenCode's permission config (`"*":"allow"`) doesn't prevent the question tool from waiting for stdin input Testing confirmed that disabling the question tool via tools config prevents the hang while still allowing all other permissions. --- src/__tests__/main/agents/definitions.test.ts | 18 ++++++++++++++++-- src/main/agents/definitions.ts | 4 +++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/__tests__/main/agents/definitions.test.ts b/src/__tests__/main/agents/definitions.test.ts index 04f4e1a4..bfb0d935 100644 --- a/src/__tests__/main/agents/definitions.test.ts +++ b/src/__tests__/main/agents/definitions.test.ts @@ -70,10 +70,24 @@ describe('agent-definitions', () => { expect(opencode?.noPromptSeparator).toBe(true); }); - it('should have opencode with default env vars for YOLO mode', () => { + it('should have opencode with default env vars for YOLO mode and disabled question tool', () => { const opencode = AGENT_DEFINITIONS.find((def) => def.id === 'opencode'); expect(opencode?.defaultEnvVars).toBeDefined(); - expect(opencode?.defaultEnvVars?.OPENCODE_CONFIG_CONTENT).toContain('external_directory'); + const configContent = opencode?.defaultEnvVars?.OPENCODE_CONFIG_CONTENT; + expect(configContent).toBeDefined(); + + // Verify it's valid JSON + const config = JSON.parse(configContent!); + + // Should have permission settings for YOLO mode + expect(config.permission).toBeDefined(); + expect(config.permission['*']).toBe('allow'); + expect(config.permission.external_directory).toBe('allow'); + + // Should disable the question tool to prevent batch mode hangs + // The question tool waits for stdin input which causes hangs in batch mode + expect(config.tools).toBeDefined(); + expect(config.tools.question).toBe(false); }); }); diff --git a/src/main/agents/definitions.ts b/src/main/agents/definitions.ts index b0653551..6b893ab5 100644 --- a/src/main/agents/definitions.ts +++ b/src/main/agents/definitions.ts @@ -200,9 +200,11 @@ export const AGENT_DEFINITIONS: AgentDefinition[] = [ imageArgs: (imagePath: string) => ['-f', imagePath], // Image/file attachment: opencode run -f /path/to/image.png -- "prompt" noPromptSeparator: true, // OpenCode doesn't need '--' before prompt - yargs handles positional args // Default env vars: enable YOLO mode (allow all permissions including external_directory) + // Also disable the question tool - it waits for stdin input which hangs batch mode // Users can override by setting customEnvVars in agent config defaultEnvVars: { - OPENCODE_CONFIG_CONTENT: '{"permission":{"*":"allow","external_directory":"allow"}}', + OPENCODE_CONFIG_CONTENT: + '{"permission":{"*":"allow","external_directory":"allow"},"tools":{"question":false}}', }, // Agent-specific configuration options shown in UI configOptions: [