[Bug] Tool-call parser rejects indented XML tags with vague "malformed" error

Resolved 💬 1 comment Opened May 31, 2026 by kurochan001 Closed Jul 3, 2026

Bug Description
---
Title: Tool-call parser rejects leading whitespace on <invoke>/<parameter> tags with a vague "malformed" error

Description:

When a tool call is emitted with the <function_calls> / <invoke> / <parameter> tags indented (i.e. with leading whitespace) instead of starting at column 0, the call fails to
parse and returns:

Your tool call was malformed and could not be parsed. Please retry.

The same call parses correctly when the tags start at the beginning of the line. The error message does not indicate the cause (leading whitespace), so it is easy to repeat the
same mistake several times in a row before identifying it.

Steps to reproduce:

  1. Emit a tool call where the <invoke> and <parameter> tags are indented, e.g.:

<invoke name="Bash">
<parameter name="command">echo hi</parameter>
</invoke>

  1. Observe the "malformed and could not be parsed" error.
  2. Re-emit the identical call with the tags at column 0 — it now parses and runs.

Requests:

  • (a) Make the parser tolerant of leading whitespace — trim/ignore indentation before the tool-call tags so indented blocks parse correctly.
  • (b) If strict parsing is intended, make the "malformed" error specific about the cause (e.g. "tool-call tags must start at the beginning of the line; leading whitespace

found"), so the model can self-correct immediately instead of retrying blindly.

Impact: Causes repeated failed tool calls and wasted turns. Note: failed calls are rejected at parse time and are not executed, so there is no risk of partial/corrupted
execution — but it interrupts progress.

---

Environment Info

  • Platform: linux
  • Terminal: wsl-Ubuntu-24.04-D
  • Version: 2.1.158
  • Feedback ID: 344f8a69-ea19-4057-a384-269425f487b9

Errors

[]

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗