Skip to content

Kimi-K2 via OpenRouter fails with tool call tokens inside thinking block #8851

Closed

Description

@graham33

Description

When using Kimi-K2 via OpenRouter with a recent OpenCode (1.1.21), I see tool call tokens in thinking sections, and the tool stops before I get a useful response.

kimi-k2-session.txt

Plugins

No response

OpenCode version

1.1.21

Steps to reproduce

Given the following prompt:

what is the tech stack of this project?

I get this thinking output in the UI:

Thinking: I'll analyze the tech stack of this project by examining the configuration files and codebase structure. <|tool_calls_section_begin|> <|tool_call_begin|> functions.bash:0 <|tool_call_argument_begin|> {"command": "ls -la", "description": "List files in current directory"} <|tool_call_end|> <|tool_call_begin|> functions.glob:1 <|tool_call_argument_begin|> {"pattern": "/.json"} <|tool_call_end|> <|tool_call_begin|> functions.glob:2 <|tool_call_argument_begin|> {"pattern": "/.{js,ts,jsx,tsx}"} <|tool_call_end|> <|tool_call_begin|> functions.glob:3 <|tool_call_argument_begin|> {"pattern": "/*.{py,java,go,rs,c,cpp}"} <|tool_call_end|> <|tool_calls_section_end|

Screenshot and/or share link

Image

Operating System

NixOS unstable

Terminal

kitty

Activity

  1. github-actions commented on Jan 16, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  2. juanfadev commented on Jan 17, 2026

    @juanfadev

    Same with KimiK2 Thinking in nvidia provider:

    Thinking: <|tool_calls_section_begin|> <|tool_call_begin|> functions.bash:1 <|tool_call_argument_begin|> {"command": "ls -la /home/user/repo", "description": "List directory"} <|tool_call_end|> <|tool_calls_section_end|>

  3. graham33 commented on Jan 18, 2026

    @graham33
    Author

    Looking at this in a bit more detail, it looks like there is an open bug with the Kimi-K2 model itself: MoonshotAI/Kimi-K2#89 and vLLM implements a workaround for it: vllm-project/vllm#28543

    This also seems similar to this issue with GLM 4.7: #6708, although there it seems more sporadic whereas with Kimi-K2 it happens a lot.

  4. qingchunnh commented on Jan 28, 2026

    @qingchunnh

    I solved this issue following #6040. Hope this helps.

  5. pascalandy commented on Jan 28, 2026

    @pascalandy

    Provider returned error

    Image

    All other models from OpenRouter are stable on my setup.
    v1.1.39

  6. wwnbb commented on Feb 12, 2026

    @wwnbb

    I solved this issue following #6040. Hope this helps.

    can you describe how you manage to fix the problem?

  7. github-actions commented on Apr 14, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingnix

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions