[Bug] Intermittent empty output from Bash/Tool execution (Silent Failure) despite correct permissions and disabled batch_tool
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:
- Enabled all relevant permissions (
bash,read,list,grep,glob). - Explicitly disabled
batch_toolinexperimentalconfig to prevent concurrency issues.
Despite these mitigations, the agent still occasionally receives empty results from standard shell commands.
Reproduction Steps
- Config: Use the configuration provided below
-
Scenario: Create a folder
/app/logswith several dummy.logfiles containing keywords like "ERROR", "WARNING", "INFO". -
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."
- 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