You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tools Fail to Unescape XML Entities (e.g., "&&" Becomes Invalid Shell Syntax) #4530
Tool fail to properly unescape XML entities in command arguments, leading to execution errors, or file content corruption. This occurs when commands include chained operators like "&&", which must be escaped as "&&" in the XML function call format to make it valid XML. However, the tool passes the escaped string directly to the shell without unescaping, causing syntax errors.
Also happens with Edit and Write tools where \n replaces newlines and a whole file becomes one line of text.
Environment:
Platform: Linux.
Tools: Bash, Write, Edit tools in opencode.
Impact:
Prevents reliable use of chained Bash commands, breaking workflows like script execution or multi-step operations.
Suggested Fix:
In the Tool handlers, add unescaping logic (e.g., replace "&" with "&", "\n" with new line, etc.) before executing the command string in the shell. Reference standard XML entity handling in tool parsers.
Additional Context:
This aligns with the safety instructions' XML-inspired format, but the parsing layer appears to miss unescaping.
Reproducible in sessions with function calls: Bash, Write, Edit.
Hmm, it appears that most failures occur silently, and occasionally you get an error report in the TUI. Mostly the effect can look like the LLM failed to follow an instruction, e.g. save a file containing the output.
Custom XML parser extracts textContent literally (no entity decoding like &→& or \n→newline), passing raw strings directly to child_process.spawn(command) in bash tool and string ops/Bun.write in edit/write tools.
Files:
packages/opencode/src/tool/bash.ts (line ~170: spawn(params.command, { – no unescape)
packages/opencode/src/tool/edit.ts (uses raw params.oldString/newString)
In the spirit of calling out excellent engineering and design....
I've found that the Pi Coding Agent is more robust and, for me has none of the issues that I've encountered in OC, or has an elegant way to resolve them.... I'm dropping out of OC issues:
Activity
taqtiqa-mark commentedon Nov 21, 2025
Another example:
rekram1-node commentedon Nov 21, 2025
we shall fix
taqtiqa-mark commentedon Nov 28, 2025
Hmm, it appears that most failures occur silently, and occasionally you get an error report in the TUI. Mostly the effect can look like the LLM failed to follow an instruction, e.g. save a file containing the output.
taqtiqa-mark commentedon Dec 28, 2025
Still seen in v1.0.193
taqtiqa-mark commentedon Dec 29, 2025
Root cause:
Custom XML parser extracts textContent literally (no entity decoding like &→& or \n→newline), passing raw strings directly to child_process.spawn(command) in bash tool and string ops/Bun.write in edit/write tools.
Files:
taqtiqa-mark commentedon Dec 29, 2025
@rekram1-node, will you accept PR that use either
fast-xml-parser,xml2jsorxmldom,xpath, etc. Or is there a preferred approach?taqtiqa-mark commentedon Feb 12, 2026
In the spirit of calling out excellent engineering and design....
I've found that the Pi Coding Agent is more robust and, for me has none of the issues that I've encountered in OC, or has an elegant way to resolve them.... I'm dropping out of OC issues: