Skip to content

fix: parse tool-call arguments shell-style, not by naive whitespace split - #1

Merged
TheSinding merged 1 commit into
mainfrom
fix/tool-call-quote-parsing
Aug 6, 2026
Merged

fix: parse tool-call arguments shell-style, not by naive whitespace split#1
TheSinding merged 1 commit into
mainfrom
fix/tool-call-quote-parsing

Conversation

@TheSinding

Copy link
Copy Markdown
Owner

Reported: /bash command="find a b c d" kept the literal quote characters and dropped everything after the first word; /bash command=find a b c (no quotes) dropped a b c entirely instead of treating them as part of the value.

Root cause: argument tokens came from strings.Fields, which has no concept of quoting and splits purely on whitespace.

Fix:

  • Tokenize with github.com/google/shlex instead, so a quoted value keeps internal spaces as one token with the quotes stripped. Malformed/unterminated quoting falls back to plain content rather than erroring.
  • parseArguments now appends any word that isn't itself a key=value for a declared property onto the previous key's value instead of dropping it, so an unquoted multi-word value is preserved too.

A value that itself needs literal quotes (e.g. a shell command like find -name "test*") needs the outer value wrapped in the other quote style, or backslash-escaped - same as a real shell. Documented in the README, covered by new tests.

…plit

Reported: /bash command="find a b c d" kept the literal quote characters
and dropped everything after the first word, and /bash command=find a b c
(no quotes) dropped "a b c" entirely instead of treating them as part of
the value.

Root cause: argument tokens came from strings.Fields, which has no concept
of quoting and splits purely on whitespace.

Fix:
- Tokenize with github.com/google/shlex instead, so a quoted value keeps
  internal spaces as one token with the quotes stripped. Malformed/
  unterminated quoting falls back to plain content rather than erroring.
- parseArguments now appends any word that is not itself a "key=value"
  for a declared property onto the previous key's value instead of
  dropping it, so an unquoted multi-word value is preserved too.

A value that itself needs literal quotes (e.g. a shell command like
find -name "test*") needs the outer key= value wrapped in the other quote
style, or backslash-escaped - same as a real shell. Documented in the
README and covered by new tests.
@TheSinding
TheSinding merged commit bbd1212 into main Aug 6, 2026
@TheSinding
TheSinding deleted the fix/tool-call-quote-parsing branch August 6, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant