Kimi-K2 icon indicating copy to clipboard operation
Kimi-K2 copied to clipboard

<|tool_calls_section_begin|> token appears in `reasoning_delta` causing agent execution failures

Open loveofcsdt opened this issue 4 months ago • 5 comments

Environment

  • Model: kimi-k2-thinking

Description

When using the kimi-k2-thinking model with streaming enabled (stream=True), I've observed that special tool-calling tokens such as <|tool_calls_section_begin|> appear within the reasoning_delta stream. This causes parsing failures in standard agent frameworks that expect reasoning_content to contain only natural language reasoning text.

Expected Behavior

According to the official documentation:

  • reasoning_content should contain the model's thinking/reasoning process
  • Tool calls should be properly structured in the tool_calls field
  • Special tokens like <|tool_calls_section_begin|> should be part of the internal token structure, not exposed in the reasoning stream

Actual Behavior

The reasoning_delta field contains raw special tokens:

stream log from our side

Image

loveofcsdt avatar Nov 07 '25 13:11 loveofcsdt

Thanks a lot for the feedback. Could you please provide more details, including: (1) this problem occurred in Moonshot API or open-source engine such as vllm? (2) What's your original prompt message? We will reproduce and further debug base on the info above.

lsw825 avatar Nov 10 '25 06:11 lsw825

same problem. i use sglang as the engine .

M1sTaker avatar Nov 11 '25 09:11 M1sTaker

same problem,openrouter api ,langchain can not use to call tools

lemonteeeeaa avatar Nov 16 '25 08:11 lemonteeeeaa

same issue. kimi-k2 0905 instruct

acodercat avatar Nov 25 '25 07:11 acodercat

same issue, vertex api endpoint

idoomblast avatar Nov 30 '25 04:11 idoomblast