tool call healing (#17) (#18)

* frontend: llama.cpp parser-hold-delta (no 500 on a shrinking partial tool-call parse; raw text logged), issue #17

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* frontend: skip a stuttered </parameter> in Qwen3-Coder calls; never 500 on a shrinking partial parse (issue #17)

llama.cpp submodule parser-hold-delta 638a7e2 (two commits on a6de9af); UPSTREAM.md lists them.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* frontend: skip blank lines before </function>; the final parse keeps streamed tool calls (issue #17)

llama.cpp submodule 4174b21: the Coder IQ1_M shard also leaves a blank line between the last
</parameter> and </function>; the hold-delta guard kept that stream alive but the final parse
threw in the diff check and the request still ended in a 500 (memcached-bisect-deep, 2026-10-21).
The grammar skips blank lines before the close tags, and a final parse that loses a streamed
call keeps the streamed calls instead of throwing. UPSTREAM.md lists it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* frontend: skip any stray close tag between Qwen3-Coder arguments (issue #17)

llama.cpp submodule: the third shape of the Coder IQ1_M slip (prime-frontend, 2026-10-21) wrote
</content> and </invoke> after the real </parameter>. One rule now covers the stutter, the blank
line and foreign close tags. UPSTREAM.md lists it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Robert KarlandClaude Fable 5.1 authored and GitHub committed 2026-10-21 09:47:23 -07:00
1 parent 2049dd2a29
commit 325594d806
2 files changed
+21 -3

No files matched your search

+20 -2
View File
@@ -5,7 +5,7 @@
| What | Where | Version |
| --- | --- | --- |
| Engines (`strata`, `strata-poly`), tools, docs | https://github.com/VecSzn/PolyStrata | tag `v0.1.45-poly.1`, commit `d0cd84dc6bd009d1d9e2191e4e28cc76b80f1ee3` |
| ggml, llama, common, mtmd, cpp-httplib | https://github.com/robertkarl/llama.cpp, branch `UnbiasedStrata`, as the submodule `third_party/llama.cpp` | commit `a6de9af3b19b5e3a5397f2c835a29a13c37664bd`: ggml-org `3cf03257f219afbe7334045ff7c6a06ac68c627d` (the commit upstream pins) plus the two parser commits below |
| ggml, llama, common, mtmd, cpp-httplib | https://github.com/robertkarl/llama.cpp, branch `UnbiasedStrata`, as the submodule `third_party/llama.cpp` | commit `385445fad49e42fa718b5e1f71668f35b7a08559`: ggml-org `3cf03257f219afbe7334045ff7c6a06ac68c627d` (the commit upstream pins) plus the six parser commits below |
Commit `0197ae86` ("Import PolyStrata v0.1.45-poly.1 (d0cd84dc) unmodified") is the upstream tree, every tracked
file, with the same tree hash as upstream's commit. `git diff 0197ae86 HEAD` is the whole story of this fork;
@@ -88,7 +88,7 @@ Recorded here because a client written for one of the two may notice.
## Changes to llama.cpp (robertkarl/llama.cpp, branch `UnbiasedStrata`)
Two commits on top of ggml-org `3cf03257`; `git -C third_party/llama.cpp diff 3cf03257 HEAD` is exactly these.
Six commits on top of ggml-org `3cf03257`; `git -C third_party/llama.cpp diff 3cf03257 HEAD` is exactly these.
- `9547d8d` (`common/parsers/qwen3-coder.cpp`): the Qwen3-Coder
tool-call grammar accepts a call's arguments in any order. Upstream takes the required ones first and the
@@ -104,6 +104,24 @@ Two commits on top of ggml-org `3cf03257`; `git -C third_party/llama.cpp diff 3c
"output does not match the expected peg-native format" (PLAN.md step 13, 2026-10-19, USTRAT-7). Whether every
required argument is present is left to the tool, as upstream already leaves it for optional-only tools.
- `1421694` (`tools/server/server-task.cpp`): a partial re-parse that reports fewer tool calls than the previous
one no longer throws (the request died with a 500 mid-stream, "Invalid diff: now finding less tool calls!"); the
previous message is kept, nothing is emitted for that token, and the raw generated text is logged. A non-partial
parse failure returns the raw text as content instead of failing the request (issue #17, 2026-10-20).
- `638a7e2` (`common/parsers/qwen3-coder.cpp`, `tests/test-chat.cpp`): the Qwen3-Coder grammar skips a stuttered
`</parameter>` close tag. Qwen3.8 Flash-Next Coder IQ1_M, sampled without the grammar, wrote the tag twice before
`</function>` in 7 of 673 requests of a BBW run (2026-10-20); each one failed the whole call and, through the diff
check above, the request. The value still ends at the first close. Test in the Qwen3-Coder section of test-chat.
- `4174b21` (`common/parsers/qwen3-coder.cpp`, `tools/server/server-task.cpp`, `tests/test-chat.cpp`): the same
shard also leaves a blank line between the last `</parameter>` and `</function>` (memcached-bisect-deep,
2026-10-21); the grammar now skips blank lines between arguments and before `</function>` and `</tool_call>`.
And the final, non-partial parse gets the same guard as the partial one: when it finds fewer tool calls than were
streamed, the streamed calls stand (arguments as last parsed) and the raw text is logged, instead of the diff
check throwing and the request ending in a 500 after the hold-delta guard had kept it alive. Two blank-line cases
in test-chat.
- `385445f` (`common/parsers/qwen3-coder.cpp`, `tests/test-chat.cpp`): the third shape (prime-frontend, 2026-10-21):
`</content>` and `</invoke>` after the real `</parameter>`, a blank line, `</parameter>` again. The stuttered-close
rule becomes general: any close tag that is not `</function>` or `</tool_call>` is skipped between arguments.
## Engine source (`src/`, `include/`)
No changes: `git diff 0197ae86 HEAD -- src include` is empty (checked 2026-10-18). The engines measured in step 9 are