Skip to content

[Engine] Inkling 2: honour a forced tool call when thinking is on - #212

Open
okada-shogo wants to merge 1 commit into
simplexai-labs:mainfrom
okada-shogo:port/serve-fix-forced-call-thinking
Open

okada-shogo wants to merge 1 commit into
simplexai-labs:mainfrom
okada-shogo:port/serve-fix-forced-call-thinking

Conversation

@okada-shogo

@okada-shogo okada-shogo commented Nov 22, 2026 •

Copy link
Copy Markdown

Problem and result

With thinking on, tool_choice naming a tool (or "required" with one tool) did nothing for Inkling 2: the model
answered in text and made no call. The same bug counted every reply token as a thinking token.

request (real template + tokenizer, thinking on, tool_choice: get_weather) main this PR alone
reply no call, content I cannot check weather. call get_weather({'city': 'Rome'})
reasoning_tokens 15 of 16 5

Thinking off is unchanged (the prompt already ends with the call's opening).

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

Service._run writes the forced call's opening when parser.state == "content" (between blocks).
InklingOutputParser never updated state: it stayed "reasoning" for the whole reply.

  • InklingOutputParser.state now follows its mode: reasoning in a thinking block, content between blocks,
    text in a text block.
  • The opening is written right after the closed thinking block, with no blank line before it (an Inkling block is its
    own message).

Validation

Passed:

  • cd terminal && ../.venv/bin/python -m unittest serve.test_inkling serve.test_server (CPU only, MockEngine):
    main 477 tests OK; this branch 479 tests OK.
  • Other serve and tokenizer suites (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.
  • The new test, run against main's code, fails as expected.
  • The table above: main vs this branch with the model's real template and tokenizer, thinking on.

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: a run with the real model on a GPU (the check above drives the service with scripted replies).

Limits

  • If the model writes a text block first, the forced call comes after that text.

Credits: VecSzn's forced-call path for Inkling 2 on main.

🤖 Generated with Claude Code

With thinking on, a named tool_choice (or "required" with one tool) was never
honoured for Inkling 2: Service._run writes the call's opening when
parser.state is "content" between blocks, but InklingOutputParser kept
OutputParser's initial state ("reasoning") for the whole reply, so the model
answered in text and no call was made. The same stale state counted every
token of the reply as a thinking token.

InklingOutputParser.state now follows its mode: "reasoning" in a thinking block,
"content" between blocks, "text" inside a text block. The opening is written
right after the closed thinking block, without the blank line other formats put
before a call (an Inkling block is a message of its own).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@okada-shogo
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
…ll when thinking is on

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant