Commit d3c0278
committed
fix(tools): tolerate smart/curly-quote JSON in tool-call arguments (no retry loop)
Device 2026-07-15: a local model (Qwythos GGUF) emitted tool-call arguments with CURLY double quotes
— {“expression”:“7 * 7”} — which strict JSON.parse rejects. parseToolCall then fell back to args={},
so the calculator got an EMPTY call, schema validation failed, and the model retried the same call
in a loop until it happened to emit straight quotes ('worked eventually').
Fix: parseToolArguments tries strict JSON first (unchanged for the common case), then retries once
with curly double quotes normalized to straight — only the string DELIMITERS, never content. The real
expression now reaches the tool on the first try. Tested through the real generateWithToolsImpl path
(fake engine boundary emits the curly-quote tool_call), red-verified by reverting the normalization.
NOTE: the raw <tool_call>…</tool_call> / [Tool Result] text seen in the reply was the model QUOTING
its own calls inside its <think> reasoning (rendered as thinking text) — the display stripper already
handles real tool-call blocks (messageContent.ts). That's the model narrating, not a strip miss.1 parent a71871b commit d3c0278
2 files changed
Lines changed: 45 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
406 | 406 | | |
407 | 407 | | |
408 | 408 | | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
409 | 432 | | |
410 | 433 | | |
411 | 434 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
94 | 115 | | |
95 | 116 | | |
96 | 117 | | |
97 | 118 | | |
98 | | - | |
| 119 | + | |
99 | 120 | | |
100 | 121 | | |
101 | 122 | | |
| |||
0 commit comments