Commit 11992dd
fix: repair truncated/trailing-extra tool call arguments from streaming
Some models (e.g. Qwen3 via vLLM) occasionally emit extra closing
braces at the end of streamed tool-call arguments, producing invalid
JSON like `{...}}}`. When replayed in conversation history, vLLM's
chat template calls json.loads() on the arguments and returns HTTP 400
"Extra data". repairToolCallArguments() strips the trailing garbage by
finding the last balanced close of the top-level JSON value.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 3c5f04a commit 11992dd
1 file changed
Lines changed: 60 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
83 | 130 | | |
84 | 131 | | |
85 | 132 | | |
| |||
2239 | 2286 | | |
2240 | 2287 | | |
2241 | 2288 | | |
2242 | | - | |
2243 | | - | |
| 2289 | + | |
| 2290 | + | |
| 2291 | + | |
| 2292 | + | |
| 2293 | + | |
| 2294 | + | |
| 2295 | + | |
| 2296 | + | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
| 2300 | + | |
2244 | 2301 | | |
2245 | 2302 | | |
2246 | | - | |
2247 | | - | |
2248 | | - | |
2249 | | - | |
| 2303 | + | |
2250 | 2304 | | |
2251 | 2305 | | |
2252 | 2306 | | |
| |||
0 commit comments