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
Same issue; I believe the error message can answer this:
time=2026-04-03T02:05:16.223Z level=WARN source=gemma4.go:287 msg="gemma4 tool call parsing failed" error="invalid character 'U' after object key:value pair" content="call:terminal{cd:<|\"|>dir<|\"|>,command:<|\"|>git add task1.yaml && git commit -m \"Update task1.yaml to use gemma4:31b\"<|\"|>}"
The issue is this line; if the command contains a quote, it will fail because it replaces <"> with ", and doesn't escape " when converting to the string that is passed to the JSON parser
No pressure to take this, but I already had the code mostly finished before I had to step away :). Your testing is much more thorough than mine, although I'm not 100% about some of the details of the test cases.
@chathaway-codes thanks for the PR, appreciate it! I'm a little uncertain of the exact correct behavior for that test case, I'm trying to experimentally figure it out right now, thanks for highlighting that. Models aren't always consistent about this sort of thing (which makes it impossible to solve it 100% of the time), but from my empirical testing, I think you're right that I was handling that case differently from what the model prefers to do. Checking some of the other escapes right now to see if it's consistent.
@chathaway-codes I pushed up that fix to my PR, will go with mine for now since I tested it more, but I've still got some other edge cases to look at tomorrow. Thanks again for pointing out that test case, was super helpful. Added you as a co-author on that commit since it wouldn't have happened tonight without you!
Activity
[-]gemma4:31b[/-][+]gemma4:31b - Tool Call Fails[/+]chathaway-codes commentedon Apr 3, 2026
Same issue; I believe the error message can answer this:
The issue is this line; if the command contains a quote, it will fail because it replaces
<">with", and doesn't escape"when converting to the string that is passed to the JSON parsermodel/parsers: fix gemma4 arg parsing when quoted strings contain "
drifkin commentedon Apr 3, 2026
Thanks for reporting! I've got what I think is an initial fix up at #15254, but still testing it
model/parsers/gemma4: fix tool call argument parsing with internal qu…
chathaway-codes commentedon Apr 3, 2026
No pressure to take this, but I already had the code mostly finished before I had to step away :). Your testing is much more thorough than mine, although I'm not 100% about some of the details of the test cases.
In particular, this one:
It's not clear to me what the correct behavior is; PR 15255 uses strconv.Quote to do the quoting.
#15255
drifkin commentedon Apr 3, 2026
@chathaway-codes thanks for the PR, appreciate it! I'm a little uncertain of the exact correct behavior for that test case, I'm trying to experimentally figure it out right now, thanks for highlighting that. Models aren't always consistent about this sort of thing (which makes it impossible to solve it 100% of the time), but from my empirical testing, I think you're right that I was handling that case differently from what the model prefers to do. Checking some of the other escapes right now to see if it's consistent.
drifkin commentedon Apr 3, 2026
@chathaway-codes I pushed up that fix to my PR, will go with mine for now since I tested it more, but I've still got some other edge cases to look at tomorrow. Thanks again for pointing out that test case, was super helpful. Added you as a co-author on that commit since it wouldn't have happened tonight without you!
model/parsers: fix gemma4 arg parsing when quoted strings contain " (o…
daniel-farina commentedon Apr 3, 2026
I got things working by merging some PRs, I'll keep on posting my findings there
https://gist.github.com/daniel-farina/87dc1c394b94e45bb700d27e9ea03193
tryblackjack commentedon Apr 5, 2026
drifkin commentedon Apr 6, 2026
@tryblackjack: this issue is already fixed, no need for a workaround
model/parsers: fix gemma4 arg parsing when quoted strings contain " (o…
model/parsers: fix gemma4 arg parsing when quoted strings contain " (o…