opencode icon indicating copy to clipboard operation
opencode copied to clipboard

[Bug] Intermittent empty output from Bash/Tool execution (Silent Failure) despite correct permissions and disabled batch_tool

Open goodmanpzh opened this issue 2 weeks ago • 6 comments

Description

I am experiencing an intermittent issue where bash commands (such as ls, grep, or cat) executed by the agent return empty output (null/void). This happens randomly: sometimes the command works perfectly, and other times it returns nothing, causing the agent to fail or fallback to inefficient methods (like reading the entire file content via read tool).

I have already attempted the following fixes, but the issue persists:

  1. Enabled all relevant permissions (bash, read, list, grep, glob).
  2. Explicitly disabled batch_tool in experimental config to prevent concurrency issues.

Despite these mitigations, the agent still occasionally receives empty results from standard shell commands.

Reproduction Steps

  1. Config: Use the configuration provided below
  2. Scenario: Create a folder /app/logs with several dummy .log files containing keywords like "ERROR", "WARNING", "INFO".
  3. Prompt: Run a task that requires multiple shell interactions, e.g.:

    "Scan all .log files in /app/logs and count how many lines contain 'ERROR', 'WARNING', and 'INFO'. Output to summary.csv."

  4. Observation: Observe the execution logs.

Observed Behavior

The agent executes a command, but the output is blank.

Log Snippet:

|  Bash     Count ERROR lines across all log files
4
|  Bash     Count WARNING lines across all log files
   <--- Empty result here, should be a number
|  Bash     Count INFO lines across all log files
   <--- Empty result here, should be a number

Because of this silent failure, the agent often assumes the file is empty or the tool failed, leading it to try to Read the specific file content directly, which is inefficient for large logs.

Expected Behavior

Standard bash commands (stdout/stderr) should be reliably captured and returned to the agent context every time, especially when batch_tool is disabled.

Configuration

{
  "permission": {
    "bash": "allow",
    "read": "allow",
    "list": "allow",
    "grep": "allow",
    "glob": "allow",
    "external_directory": "allow"
  },
  "experimental": {
    "batch_tool": false
  }
}

Environment

  • OpenCode Version: (Latest)
  • Provider: OpenAI Compatible (Local/Custom)
  • OS/Container: Docker, Linux

Possible Cause

It seems like a race condition or a buffer flushing issue in the stdio capture logic of the tool execution layer. Even when serialized (non-batched), the output buffer might be closing before the command fully flushes its stdout to the agent's context.

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

goodmanpzh avatar Jan 03 '26 12:01 goodmanpzh