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.
This commit is contained in:
Pedram Amini
2026-02-02 22:33:24 -06:00
parent f5334493d0
commit e6a0faed9a
2 changed files with 19 additions and 3 deletions

View File

@@ -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);
});
});

View File

@@ -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: [