anomalyco / anomalyco/opencode
bash tool drops stdout for every command after a newline; only the first command's output is captured
@nexxeln is already working on this.
Since Aug 12, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
When a bash tool call contains multiple commands separated by newlines, the tool's output capture only shows the first command's stdout/stderr. Subsequent commands' output is silently dropped, even though the commands execute successfully.
When the same multi-command script is run with commands chained by ; (semicolons) on a single line, all output is captured correctly.
This is a real problem for agents that emit multi-line commands to test for side effects, e.g.:
memorix memory store --text "..."
echo "EXIT=$?" # never shows in output
The user cannot tell whether the first command succeeded.
Environment
- opencode version: 1.18.16 (from
F:\npm-global\node_modules\opencode-ai\package.json) - OS: Windows 11 (probably affects all OS, but most noticeable on Windows where PowerShell multi-line pipes are more common)
- Shell wrapper: custom
~/.config/opencode/pwsh.cmd(PowerShell 7+)
Steps to reproduce
Test 1 — multi-line commands (broken):
echo "first"
echo "second"
echo "third"
Output captured by opencode:
first
second and third are silently dropped.
Test 2 — same commands joined with ; (works):
echo "first"; echo "second"; echo "third"
Output:
first
second
third
Expected
Both styles should produce the same output:
first
second
third
Actual
Test 1 only shows first. Test 2 works as expected.
Real-world impact
This caused me to lose significant debugging time. I was running a long sequence like:
memorix memory store --text "long text..."
memorix memory recent --limit 3
and seeing only the first command's output. I assumed memorix memory store was silently failing (no output, no error) when in fact the second command was being executed but its output was dropped. The first command had succeeded and the observation was stored — I just couldn't see the confirmation.
For an agent doing structured verification ("run command, then check result"), this is a correctness bug, not just a display nuisance.
Likely cause
My guess: opencode's bash tool splits the script on newlines and treats each line as a separate sub-invocation, but only the first sub-invocation's output stream is wired back to the assistant. Or it uses read -d '\n' style parsing on stdout that stops at the first newline. Either way, semicolon-joining works because it's a single-line script that the tool processes as one.
Workaround
Always use ; to chain commands, not newlines. Single-command scripts work fine. Long compound scripts should be:
cmd1; cmd2; cmd3
instead of
cmd1
cmd2
cmd3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.