opencode zen models tool calls are not parsed correctly mid conversation
Description
Switching models mid conversation leads to tool calls not being parsed.
Happened to me today while switching from sonnet 4.5 to kimi k2, happened to me in the past with GLM and big pickle as well
OpenCode version
0.15.29
Steps to reproduce
- started conversation in plan mode with sonnet 4.5 (anthropic api key)
- switched to build mode with kimi k2 (zen)
- Got weird output that looks to me like tool calls that are not parsed correctly
Screenshot and/or share link
Operating System
Arch
Terminal
Ghostty + tmux
This issue might be a duplicate of existing issues. Please check:
- #3035: Model switching between reasoning and non-reasoning models causing tool call issues
- #1021: Tool Calls Section End Token parsing failures with various models
- #1018: Failed tool calls when using Groq + Kimi K2 (closed but similar)
- #2903: GLM-4.6 model losing tool use capability (closed but similar pattern)
- #1522: Kimi K2 stopping mid-chat issues
Feel free to ignore if none of these address your specific case.
Yeah looks like a duplicate of 1021
Addition: when switching back to anthropic the problem disappears
this is just the model failing to call tools, it isnt calling them correctly, this can happen for many providers and models just happens more frequently with some than others
This happens consistently with kimi k2 thinking. Is there any recommended way to work around it? @rekram1-node
This should be fixed in next release: https://github.com/sst/opencode/commit/df64612d540a86d44e12c7f1c516b8ab62a28b65
I tried 1.0.150 and it's still happening. Not sure if it's happening less or not.
@DamianPereira yeah this is an upstream bug for us, our kimi k2 thinking provider (for zen) has a bug on their end, once they fix it this should resolve.
Basically if I enable proper interleaved thinking for kimi k2 thinking on their inference rn, it would loop infinitely (bug on their end), so rn I can't use interleaved thinking for it yet which is why sometimes it does dumb stuff like what you are seeing there.
I'll update once it has been addressed!
Thanks a lot for the fix and quick answer.
can confirm the fix is working beautifully, thanks 👍🏻