Repository navigation
[Engine] Inkling 2: a tool call whose JSON holds <|end_message|> is still a call - #211
Open
okada-shogo wants to merge 1 commit into
Open
okada-shogo wants to merge 1 commit into
okada-shogo wants to merge 1 commit into
Conversation
…call
InklingOutputParser ended a call block at the first <|end_message|> (or
<|message_model|>), even inside a JSON string. A call such as
python({"code": "print('<|end_message|>')"}) - the model can write the tag's
text with ordinary tokens - was cut there, its JSON did not parse, and the
client got the raw block as text instead of the call. llama.cpp 29b52d398b
parses it as the call.
The block now ends at the first tag outside the JSON's strings. If every tag is
inside a string, the JSON has not closed: the parser waits for more, and at the
end of the reply it ends at the first tag as before (the block is then text).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
okada-shogo
marked this pull request as ready for review
November 22, 2026 21:27
okada-shogo
added a commit
to okada-shogo/PolyStrata
that referenced
this pull request
Nov 23, 2026
…holds <|end_message|> is still a call Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and result
InklingOutputParserended a call block at the first<|end_message|>, also when it was inside a JSON string. Themodel can write that text with ordinary tokens, for example in code:
On main the client got this block as plain text and no call. With this PR it is the call
python({"code": "print('<|end_message|>')"}).Related discussion
Split out of #200, as the maintainer asked there:
#200 (comment)
The bug was found by the Inkling 2 golden tests, which follow in a separate draft PR (
port/serve-fixtures).Approach
The call block now ends at the first tag outside the JSON's strings. If every tag seen so far is inside a string, the
parser waits for more text; at the end of the reply it falls back to the first tag, as before.
Validation
Passed:
cd terminal && ../.venv/bin/python -m unittest serve.test_inkling serve.test_server(CPU only): main 477 tests OK;this branch 478 tests OK.
serve.test_family_parsers,test_lfm2,test_flint,test_gemma,test_prompt_encoder,test_stop_holdback,test_responses,test_tool_addition,test_tool_markup_retry,tools.test_strata_ornith122,tools.test_tokenizer_plain_spans,tools.test_setup_inkling,tools.test_hy4_tokenizer): 211 OK (1 skipped), the same on main and on this branch.Failed: On unchanged main d1f711e, serve.test_inkling + serve.test_server failed 1 of 477 once in 3 runs (the output didn't name the test; it is intermittent on main itself, not in this change). The branch runs passed every time.
Not run:
(
port/serve-fixtures), not on a separate llama.cpp run.Limits
finish(): streaming stalls, but thefinal output is the same as on main.
Credits: VecSzn's
InklingOutputParseron main.🤖 Generated with Claude Code