Parse every call:name{...} block in a decoded tool-call segment.
Strict scan first (unchanged behavior on well-formed input). On the two
ways a small model mangles THIS family's syntax specifically —
(a) generation truncated mid-call (an unterminated <|"|> string or a
brace that never closes, both hit_max_tokens artifacts) and (b) a
trailing comma surviving gemmaArgsToJson's conversion to JSON — the
repair pass recovers by treating "ran off the end of the text" as an
implicit close (mirrors closeUnbalanced's brace-stack unwind, adapted
for the <|"|>-quoted syntax) and re-running stripTrailingCommas on the
converted JSON. Recovered calls are tagged repaired/repairs; a segment
that still can't be recovered throws exactly as before.
Parse every
call:name{...}block in a decoded tool-call segment.Strict scan first (unchanged behavior on well-formed input). On the two ways a small model mangles THIS family's syntax specifically — (a) generation truncated mid-call (an unterminated
<|"|>string or a brace that never closes, both hit_max_tokens artifacts) and (b) a trailing comma survivinggemmaArgsToJson's conversion to JSON — the repair pass recovers by treating "ran off the end of the text" as an implicit close (mirrors closeUnbalanced's brace-stack unwind, adapted for the<|"|>-quoted syntax) and re-running stripTrailingCommas on the converted JSON. Recovered calls are tagged repaired/repairs; a segment that still can't be recovered throws exactly as before.