Skip to content

chat : Allow K2 Horizon tool call during thought - #32993

Merged
pwilkin merged 1 commit into
ggml-org:masterfrom
jaredmeaux:k2-horizon-unclosed-toolcall
Nov 28, 2026
Merged

pwilkin merged 1 commit into
ggml-org:masterfrom
jaredmeaux:k2-horizon-unclosed-toolcall

Conversation

@jaredmeaux

Copy link
Copy Markdown
Contributor

Overview

Allow tool calls that would otherwise appear inside reasoning/thinking blocks for K2 Horizon.

K2 Horizon models can emit tool calls without closing the thinking block. Without this
fix the parser would only stop on explicit end tag, and the tool call was lost without
executing. With this PR we now end reasoning before the tool call starts.
In short, when reasoning mentions <ifm|tool_calls>, we end reasoning there.

My tests cover this case at medium and high effort.

This fixes #32972, and is the same pattern as #32232 (Gemma4) and #32271 (Ministral-3).

Additional information

#30335: the K2 medium-effort fix says this unclosed case "is not covered".
#30246: K2 Horizon: low/medium effort leaves final text and tool calls in reasoning_content

Requirements

I have used Claude Opus 5.5 to run and score benchmarks, help find the K2 parser, draft
the fix and test, and see how others have resolved this for other models. I have carefully
examined all changes and tested with my local benchmarks.

I have used GPT 6.2 Sol to code review twice.

Allow tool calls that would otherwise appear inside reasoning/thinking blocks for K2 Horizon.

K2 Horizon models can emit tool calls without closing the thinking block. Without this
fix the parser would only stop on explicit end tag, and the tool call was lost without
executing. With this PR we now end reasoning before the tool call starts.
In short, when reasoning mentions `<ifm|tool_calls>`, we end reasoning there.

My tests cover this case at medium and high effort.

This fixes ggml-org#32972, and is the same pattern as ggml-org#32232 (Gemma4) and ggml-org#32271 (Ministral-3).

- I have read and agree with the [contributing guidelines](https://github.com/ggml-org/llama.cpp/blob/master/CONTRIBUTING.md)

I have used Opus to run and score benchmarks, help find the K2 parser, draft
the fix and test, and see how others have resolved this for other models. I have carefully
examined all changes and tested with my local benchmarks.

I have used Sol to code review twice.

Assisted-by: Claude Opus 5.5
Assisted-by: GPT 6.2 Sol
@jaredmeaux
jaredmeaux requested review from a team and pwilkin as code owners November 25, 2026 00:41
@github-actions github-actions Bot added the testing Everything test related label Nov 25, 2026

@aldehir aldehir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@aldehir aldehir added the merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. label Nov 26, 2026
@pwilkin
pwilkin merged commit f16e79d into ggml-org:master Nov 28, 2026
17 checks passed
edwardyoon pushed a commit to edwardyoon/focus-llama that referenced this pull request Dec 1, 2026
Allow tool calls that would otherwise appear inside reasoning/thinking blocks for K2 Horizon.

K2 Horizon models can emit tool calls without closing the thinking block. Without this
fix the parser would only stop on explicit end tag, and the tool call was lost without
executing. With this PR we now end reasoning before the tool call starts.
In short, when reasoning mentions `<ifm|tool_calls>`, we end reasoning there.

My tests cover this case at medium and high effort.

This fixes ggml-org#32972, and is the same pattern as ggml-org#32232 (Gemma4) and ggml-org#32271 (Ministral-3).

- I have read and agree with the [contributing guidelines](https://github.com/ggml-org/llama.cpp/blob/master/CONTRIBUTING.md)

I have used Opus to run and score benchmarks, help find the K2 parser, draft
the fix and test, and see how others have resolved this for other models. I have carefully
examined all changes and tested with my local benchmarks.

I have used Sol to code review twice.

Assisted-by: Claude Opus 5.5
Assisted-by: GPT 6.2 Sol
(cherry picked from commit f16e79d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Eval bug: K2-Horizon-MoVA-36B tool-calls during reasoning are not processed

3 participants