opencode icon indicating copy to clipboard operation
opencode copied to clipboard

opencode zen models tool calls are not parsed correctly mid conversation

Open tsah opened this issue 2 months ago • 11 comments

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

  1. started conversation in plan mode with sonnet 4.5 (anthropic api key)
  2. switched to build mode with kimi k2 (zen)
  3. Got weird output that looks to me like tool calls that are not parsed correctly

Screenshot and/or share link

Image

Operating System

Arch

Terminal

Ghostty + tmux

tsah avatar Oct 30 '25 07:10 tsah

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.

github-actions[bot] avatar Oct 30 '25 07:10 github-actions[bot]

Yeah looks like a duplicate of 1021

tsah avatar Oct 30 '25 07:10 tsah

Addition: when switching back to anthropic the problem disappears

tsah avatar Oct 30 '25 07:10 tsah

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

rekram1-node avatar Oct 30 '25 14:10 rekram1-node

This happens consistently with kimi k2 thinking. Is there any recommended way to work around it? @rekram1-node

Image

Adictya avatar Dec 05 '25 05:12 Adictya

This should be fixed in next release: https://github.com/sst/opencode/commit/df64612d540a86d44e12c7f1c516b8ab62a28b65

rekram1-node avatar Dec 09 '25 22:12 rekram1-node

I tried 1.0.150 and it's still happening. Not sure if it's happening less or not.

Image

DamianPereira avatar Dec 12 '25 07:12 DamianPereira

@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.

rekram1-node avatar Dec 12 '25 07:12 rekram1-node

I'll update once it has been addressed!

rekram1-node avatar Dec 12 '25 07:12 rekram1-node

Thanks a lot for the fix and quick answer.

DamianPereira avatar Dec 12 '25 07:12 DamianPereira

can confirm the fix is working beautifully, thanks 👍🏻

Adictya avatar Dec 13 '25 04:12 Adictya