[PR #10382] fix: parse Kimi K2 Thinking tool calls with special tokens #13426

Closed
opened 2026-02-16 18:18:17 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/10382

State: closed
Merged: No


Kimi K2 Thinking model uses special tokens for tool calls instead of standard OpenAI format:
<|tool_calls_section_begin|><|tool_call_begin|>functions.name:idx<|tool_call_argument_begin|>{...}<|tool_call_end|><|tool_calls_section_end|>

This PR adds:

  • kimi.ts: Parser for Kimi special token format
  • Support for toolCallFormat flag in ZenData model schema
  • Auto-detection fallback when flag is not set
  • Both streaming and non-streaming response handling

The parser activates when:

  1. Model has toolCallFormat: "kimi" in config, OR
  2. Response content contains <|tool_call tokens (auto-detect)

Fixes #9878

PR also: https://github.com/anomalyco/models.dev/pull/705

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/10382 **State:** closed **Merged:** No --- Kimi K2 Thinking model uses special tokens for tool calls instead of standard OpenAI format: <|tool_calls_section_begin|><|tool_call_begin|>functions.name:idx<|tool_call_argument_begin|>{...}<|tool_call_end|><|tool_calls_section_end|> This PR adds: - kimi.ts: Parser for Kimi special token format - Support for toolCallFormat flag in ZenData model schema - Auto-detection fallback when flag is not set - Both streaming and non-streaming response handling The parser activates when: 1. Model has toolCallFormat: "kimi" in config, OR 2. Response content contains <|tool_call tokens (auto-detect) Fixes #9878 PR also: https://github.com/anomalyco/models.dev/pull/705
yindo added the pull-request label 2026-02-16 18:18:17 -05:00
yindo closed this issue 2026-02-16 18:18:17 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13426