Kimi-K2 via OpenRouter fails with tool call tokens inside thinking block
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.
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
Operating System
NixOS unstable
Terminal
kitty