Repository navigation
[Fix] kimi_k3: Use uuid tool_call_id instead of history-count id - #45972
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This comment has been minimized.
This comment has been minimized.
JustinTong0323
left a comment
There was a problem hiding this comment.
The fix is right: K3's encoder treats tool_call ids as opaque (index comes from position), so the uuid path is safe, and the history-count id genuinely repeats when a client sends a shorter history. Verified test_serving_chat.py green on this head (160 passed).
One request before merge: add a regression test pinning that two _process_tool_call_id calls with the same (call_item, history_tool_calls_cnt) return different ids for kimi_k3. Nothing currently guards the uniqueness contract, so a future diff re-adding a deterministic K3 id would silently reintroduce the duplicate-id bug. #33343 (same fix, stale) has usable test shapes — a frozen-history non-streaming case and a kimi_k2-stays-positional guard; close that PR as superseded when this lands.
Process: retitle to [Fix] kimi_k3: ... for the title check.
|
/rerun-failed-ci |
|
/rerun-failed-ci |
Pin that repeated (call_item, history_cnt) inputs mint distinct ids, so a future deterministic-id change cannot silently reintroduce the duplicate-id bug. Trim the comment above the uuid branch to the load-bearing why.
|
/rerun-failed-ci |
Port sgl-project#48775 to sglang-processor. SGLang now streams a Kimi-K3 call's name and `{` once its header is complete, string values as they arrive and typed values once they close; the port still sent each call whole once `<|close|>call<|sep|>` arrived, so 28 of the 46 tool-parity cases had drifted. `kimi_k3.rs` streams through a port of `_stream_calls`, including skipping malformed XTML, and headers a call or tools close cuts short, as the one-shot parse does. A call the stream leaves open is incomplete, and a stop then does not finish as `tool_calls`: `ToolDetector::has_incomplete_call` carries that into `openai/chat.rs` and `parser/tools.rs`, as `serving_chat`'s `_incomplete_tool_call_indices` does. Regenerate `tool_parity/kimik3.json` and add malformed, cut-header and split-value inputs. In `openai_parity/kimi-k3.json`, update the two streamed tool cases and add `tools_stream_unclosed`, generated with Kimi-K3 on the OpenAI wire and its pre-sgl-project#45972 ids, which this path still writes.
Summary
Remove the
kimi_k3special case inOpenAIServingChat._process_tool_call_idso Kimi-K3 gets the defaultcall_<uuid>tool call id.Why
name:idxformat. Only Kimi-K2's chat template requiresfunctions.{name}:{idx}, and that path is unchanged.tool_useids (e.g. Claude Code) then drop the call.Test plan
test_kimi_k3_tool_call_id_unique_when_history_count_repeats: two_process_tool_call_idcalls with the same history count return differentcall_ids.test_kimi_k2_*_tool_call_id_with_historytests still pin K2's positionalfunctions.{name}:{idx}ids.🤖 Generated with Claude Code
CI States
Latest PR Test (Base): ❌ Run #40581259797
Latest PR Test (Extra): ❌ Run #40581259862
Latest PR Test (AMD ROCm 10): ❌ Run #40581259763