Malformed thinking block in toolcall (glm-4.7-free) #3791

Closed
opened 2026-02-16 17:41:28 -05:00 by yindo · 8 comments
Owner

Originally created by @kevingatera on GitHub (Dec 23, 2025).

Originally assigned to: @fwang on GitHub.

Description

There seems to be a malformed tool call in the thinking block on the glm-4.7-free available via opencode zen. I understand it's in beta, but I wanted to report this just in case, since there was no feedback button within opencode. I had to re-ask but was confused on whether the chat was still ongoing because it had stopped but I re-asked the question again (see screenshots attached)

OpenCode version

1.0.191

Steps to reproduce

It's intermittent so I am not sure

Screenshot and/or share link

Image Image

Operating System

linux (Nobara)

Terminal

N/A

Originally created by @kevingatera on GitHub (Dec 23, 2025). Originally assigned to: @fwang on GitHub. ### Description There seems to be a malformed tool call in the thinking block on the glm-4.7-free available via opencode zen. I understand it's in beta, but I wanted to report this just in case, since there was no feedback button within opencode. I had to re-ask but was confused on whether the chat was still ongoing because it had stopped but I re-asked the question again (see screenshots attached) ### OpenCode version 1.0.191 ### Steps to reproduce It's intermittent so I am not sure ### Screenshot and/or share link <img width="2024" height="274" alt="Image" src="https://github.com/user-attachments/assets/32cd3080-e947-412d-a211-eacc12abc31b" /> <img width="2092" height="754" alt="Image" src="https://github.com/user-attachments/assets/bc219a63-a96e-4705-9098-d0c94ae7c96d" /> ### Operating System linux (Nobara) ### Terminal N/A
yindo added the bugzen labels 2026-02-16 17:41:28 -05:00
yindo closed this issue 2026-02-16 17:41:28 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 23, 2025):

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

  • #3596: SSE Stream Bug: Out-of-Order thinking_delta via LiteLLM → AWS Bedrock - similar malformed thinking block issues in streaming
  • #3077: Expected thinking or redacted_thinking, but found tool_use - related thinking block ordering problems
  • #3743: Loop in certain models - GLM models occasionally showing tool call malfunction issues
  • #3444: GLM-4.6 model gets stuck in infinite loop - similar behavior with GLM models getting stuck on tool calls

Feel free to ignore if your specific case with glm-4.7-free differs from these issues.

@github-actions[bot] commented on GitHub (Dec 23, 2025): This issue might be a duplicate of existing issues. Please check: - #3596: SSE Stream Bug: Out-of-Order thinking_delta via LiteLLM → AWS Bedrock - similar malformed thinking block issues in streaming - #3077: Expected `thinking` or `redacted_thinking`, but found `tool_use` - related thinking block ordering problems - #3743: Loop in certain models - GLM models occasionally showing tool call malfunction issues - #3444: GLM-4.6 model gets stuck in infinite loop - similar behavior with GLM models getting stuck on tool calls Feel free to ignore if your specific case with glm-4.7-free differs from these issues.
Author
Owner

@ramarivera commented on GitHub (Dec 23, 2025):

+1ing this one, the "it seems to have stopped completely" thing happens both on Zen GLM 4.7 and Z.AI coding plan's

@ramarivera commented on GitHub (Dec 23, 2025): +1ing this one, the "it seems to have stopped completely" thing happens both on Zen GLM 4.7 and Z.AI coding plan's
Author
Owner

@rekram1-node commented on GitHub (Dec 23, 2025):

glm-4.7-free was incorrectly not configured as an interleaved reasoning model.

This should be fixed if you do opencode models --refresh

Your cache will automatically refresh but this just forces it to so that you can have the fix sooner

@rekram1-node commented on GitHub (Dec 23, 2025): glm-4.7-free was incorrectly not configured as an interleaved reasoning model. This should be fixed if you do `opencode models --refresh` Your cache will automatically refresh but this just forces it to so that you can have the fix sooner
Author
Owner

@rekram1-node commented on GitHub (Dec 23, 2025):

fix

@rekram1-node commented on GitHub (Dec 23, 2025): [fix](https://github.com/sst/models.dev/commit/e174f5400fbd4c0e0c0f0982bd9a6690242a9c42)
Author
Owner

@ramarivera commented on GitHub (Dec 23, 2025):

oh this is really sad for me :(
I was working on a PR to to detect and extract the tool call from inside the thinking block cuz I assumed it was a GLM issue that required normalization in packages/opencode/src/provider/transform.ts

Guess I should have asked first 😓

@ramarivera commented on GitHub (Dec 23, 2025): oh this is really sad for me :( I was working on a PR to to detect and extract the tool call from inside the thinking block cuz I assumed it was a GLM issue that required normalization in `packages/opencode/src/provider/transform.ts` Guess I should have asked first 😓
Author
Owner

@ramarivera commented on GitHub (Dec 24, 2025):

so, even with this fix, I still get tool calls in thinking blocks which causes the opencode workflow to stop e.g.

Thinking: <tool_call>bash<arg_key>command</arg_key><arg_value>cat packages/portal/.generation-cache.json | jq '."volume", "artifact", "generatedAt", "tokens" | select(.volume == "openspec") | .artifact | .generatedAt | .tokens' 2>/dev/null</arg_value><arg_key>description</arg_key><arg_value>Check cache for openspec artifacts</arg_value></tool_call>

EDIT: more examples

Thinking: <tool_call>use_skill<arg_key>skill</arg_key><arg_value>handoff</arg_value></tool_call>
@ramarivera commented on GitHub (Dec 24, 2025): so, even with this fix, I still get tool calls in thinking blocks which causes the opencode workflow to stop e.g. ``` Thinking: <tool_call>bash<arg_key>command</arg_key><arg_value>cat packages/portal/.generation-cache.json | jq '."volume", "artifact", "generatedAt", "tokens" | select(.volume == "openspec") | .artifact | .generatedAt | .tokens' 2>/dev/null</arg_value><arg_key>description</arg_key><arg_value>Check cache for openspec artifacts</arg_value></tool_call> ``` EDIT: more examples ``` Thinking: <tool_call>use_skill<arg_key>skill</arg_key><arg_value>handoff</arg_value></tool_call> ```
Author
Owner

@crystech commented on GitHub (Dec 25, 2025):

so, even with this fix, I still get tool calls in thinking blocks which causes the opencode workflow to stop e.g.

Thinking: <tool_call>bash<arg_key>command</arg_key><arg_value>cat packages/portal/.generation-cache.json | jq '."volume", "artifact", "generatedAt", "tokens" | select(.volume == "openspec") | .artifact | .generatedAt | .tokens' 2>/dev/null</arg_value><arg_key>description</arg_key><arg_value>Check cache for openspec artifacts</arg_value></tool_call>

EDIT: more examples

Thinking: <tool_call>use_skill<arg_key>skill</arg_key><arg_value>handoff</arg_value></tool_call>

+1 here. same issues on GLM 4.7 local llm

@crystech commented on GitHub (Dec 25, 2025): > so, even with this fix, I still get tool calls in thinking blocks which causes the opencode workflow to stop e.g. > > ``` > Thinking: <tool_call>bash<arg_key>command</arg_key><arg_value>cat packages/portal/.generation-cache.json | jq '."volume", "artifact", "generatedAt", "tokens" | select(.volume == "openspec") | .artifact | .generatedAt | .tokens' 2>/dev/null</arg_value><arg_key>description</arg_key><arg_value>Check cache for openspec artifacts</arg_value></tool_call> > ``` > > EDIT: more examples > > ``` > Thinking: <tool_call>use_skill<arg_key>skill</arg_key><arg_value>handoff</arg_value></tool_call> > ``` +1 here. same issues on GLM 4.7 local llm
Author
Owner

@rekram1-node commented on GitHub (Dec 25, 2025):

if u are still running into it it is entirely dependent on ir provider, if opencode is properly sending thinking chunks (the interleaved setting for model is correct) then it is on the provider of the model to properly parse the tool calls out and send them as such

@rekram1-node commented on GitHub (Dec 25, 2025): if u are still running into it it is entirely dependent on ir provider, if opencode is properly sending thinking chunks (the interleaved setting for model is correct) then it is on the provider of the model to properly parse the tool calls out and send them as such
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3791