GLM 4.7 on Zai coding plan puts tool calls inside the thinking/reasoning tag. #4114

Open
opened 2026-02-16 17:42:40 -05:00 by yindo · 26 comments
Owner

Originally created by @greggh on GitHub (Jan 2, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

This happens to me about 15 times a day, and it forces me to start a new session because the session with that call in the thinking tag keeps happening and more errors and failures to call the right tools starts to happen.

Restarting in a new session it will go an hour or so before doing it again and needing a restart.

OpenCode version

1.0.223

Steps to reproduce

  1. Choose Zai coding plan and give it your API Key.
  2. Use GLM 4.7 for awhile.
  3. It usually happens after context goes above 100k.

Screenshot and/or share link

Image

Operating System

macOS 26.1

Terminal

Kitty

p.s. OpenCode is awesome.

Originally created by @greggh on GitHub (Jan 2, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description This happens to me about 15 times a day, and it forces me to start a new session because the session with that call in the thinking tag keeps happening and more errors and failures to call the right tools starts to happen. Restarting in a new session it will go an hour or so before doing it again and needing a restart. ### OpenCode version 1.0.223 ### Steps to reproduce 1. Choose Zai coding plan and give it your API Key. 2. Use GLM 4.7 for awhile. 3. It usually happens after context goes above 100k. ### Screenshot and/or share link <img width="1800" height="556" alt="Image" src="https://github.com/user-attachments/assets/ed24858f-82cd-4478-adeb-cad506e0b78f" /> ### Operating System macOS 26.1 ### Terminal Kitty p.s. OpenCode is awesome.
yindo added the bug label 2026-02-16 17:42:40 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 2, 2026):

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

  • #6486: Error "reasoning part reasoning-0 not found" from tool calls using GLM 4.5 Air

Both issues involve GLM models having problems with reasoning/thinking tags and tool calls, though with different error messages. Checking #6486 may provide additional context for understanding and fixing the issue.

Feel free to ignore if this doesn't address your specific case.

@github-actions[bot] commented on GitHub (Jan 2, 2026): This issue might be a duplicate of existing issues. Please check: - #6486: Error "reasoning part reasoning-0 not found" from tool calls using GLM 4.5 Air Both issues involve GLM models having problems with reasoning/thinking tags and tool calls, though with different error messages. Checking #6486 may provide additional context for understanding and fixing the issue. Feel free to ignore if this doesn't address your specific case.
Author
Owner

@arsham commented on GitHub (Jan 2, 2026):

This is actually handy. I was wondering when we would see such thing. Basically during the reasoning phase, the model could use a tool call to enrich its reasoning.

@arsham commented on GitHub (Jan 2, 2026): This is actually handy. I was wondering when we would see such thing. Basically during the reasoning phase, the model could use a tool call to enrich its reasoning.
Author
Owner

@greggh commented on GitHub (Jan 2, 2026):

This is actually handy. I was wondering when we would see such thing. Basically during the reasoning phase, the model could use a tool call to enrich its reasoning.

Definitely. I am not saying it's a horrible thing that it's calling a tool while reasoning, but isn't the best that the tool call doesn't actually happen and the session gets into a weird state for me.

@greggh commented on GitHub (Jan 2, 2026): > This is actually handy. I was wondering when we would see such thing. Basically during the reasoning phase, the model could use a tool call to enrich its reasoning. Definitely. I am not saying it's a horrible thing that it's calling a tool while reasoning, but isn't the best that the tool call doesn't actually happen and the session gets into a weird state for me.
Author
Owner

@rekram1-node commented on GitHub (Jan 2, 2026):

how consistent is this?

@rekram1-node commented on GitHub (Jan 2, 2026): how consistent is this?
Author
Owner

@msmirnyagin commented on GitHub (Jan 2, 2026):

@rekram1-node haha, Interleaved thinking
We support interleaved thinking by default (supported since GLM-4.5), allowing GLM to think between tool calls and after receiving tool results. This enables more complex, step-by-step reasoning: interpreting each tool output before deciding what to do next, chaining multiple tool calls with reasoning steps, and making finer-grained decisions based on intermediate results. https://docs.z.ai/guides/capabilities/thinking-mode

@msmirnyagin commented on GitHub (Jan 2, 2026): @rekram1-node haha, Interleaved thinking We support interleaved thinking by default (supported since GLM-4.5), allowing GLM to think between tool calls and after receiving tool results. This enables more complex, step-by-step reasoning: interpreting each tool output before deciding what to do next, chaining multiple tool calls with reasoning steps, and making finer-grained decisions based on intermediate results. https://docs.z.ai/guides/capabilities/thinking-mode
Author
Owner

@rekram1-node commented on GitHub (Jan 2, 2026):

@msmirnyagin we do send reasoning content back under the reasoning_content field, hmmm

Ill look

Only thing I see that may be an issue is “clear_thinking”: false but for the coding plan it says enabled by default hm

@rekram1-node commented on GitHub (Jan 2, 2026): @msmirnyagin we do send reasoning content back under the reasoning_content field, hmmm Ill look Only thing I see that may be an issue is `“clear_thinking”: false` but for the coding plan it says enabled by default hm
Author
Owner

@rekram1-node commented on GitHub (Jan 2, 2026):

@greggh anyway u could share a session this happened?

opencode export > session.json

Are you using any plugins that could be interferring?

@rekram1-node commented on GitHub (Jan 2, 2026): @greggh anyway u could share a session this happened? `opencode export > session.json` Are you using any plugins that could be interferring?
Author
Owner

@FurryWolfX commented on GitHub (Jan 3, 2026):

I also encountered the same issue. It doesn't happen all the time, and I'm not sure what triggers it.

@FurryWolfX commented on GitHub (Jan 3, 2026): I also encountered the same issue. It doesn't happen all the time, and I'm not sure what triggers it.
Author
Owner

@heimoshuiyu commented on GitHub (Jan 3, 2026):

I have also encountered this situation, especially when the context is long (>128k). I guess this is because glm4.7 was further trained based on glm4.5, and glm4.5 only supports a 128k context. This also explains why glm4.7’s accuracy declines beyond 100k, starts speaking nonsense, and mixes Chinese and English.

This is purely speculation without any evidence. Basically, when the context reaches around 100k, I manually execute /compact to avoid this issue.

@heimoshuiyu commented on GitHub (Jan 3, 2026): I have also encountered this situation, especially when the context is long (>128k). I guess this is because glm4.7 was further trained based on glm4.5, and glm4.5 only supports a 128k context. This also explains why glm4.7’s accuracy declines beyond 100k, starts speaking nonsense, and mixes Chinese and English. This is purely speculation without any evidence. Basically, when the context reaches around 100k, I manually execute /compact to avoid this issue.
Author
Owner

@greggh commented on GitHub (Jan 3, 2026):

@greggh anyway u could share a session this happened?

opencode export > session.json

Are you using any plugins that could be interferring?

I can make up a fake session later, my real work that this is happening on I can't share (I don't own, contract, ...). I'll grab some other code and get it to the point it fails.

As for consistency, I get it more than 10 times a day.

@greggh commented on GitHub (Jan 3, 2026): > [@greggh](https://github.com/greggh) anyway u could share a session this happened? > > `opencode export > session.json` > > Are you using any plugins that could be interferring? I can make up a fake session later, my real work that this is happening on I can't share (I don't own, contract, ...). I'll grab some other code and get it to the point it fails. As for consistency, I get it more than 10 times a day.
Author
Owner

@ahmedrowaihi commented on GitHub (Jan 3, 2026):

Ahhh GLM-4.7 on Zai cofing plan | +2

Image
@ahmedrowaihi commented on GitHub (Jan 3, 2026): Ahhh GLM-4.7 on Zai cofing plan | +2 <img width="780" height="84" alt="Image" src="https://github.com/user-attachments/assets/27f678d4-7cad-4e76-a089-e45e969d66d5" />
Author
Owner

@gsxdsm commented on GitHub (Jan 3, 2026):

Happening on my end also

@gsxdsm commented on GitHub (Jan 3, 2026): Happening on my end also
Author
Owner

@rekram1-node commented on GitHub (Jan 3, 2026):

anyway u could share a session this happened?

opencode export > session.json

@rekram1-node commented on GitHub (Jan 3, 2026): anyway u could share a session this happened? opencode export > session.json
Author
Owner

@ramarivera commented on GitHub (Jan 4, 2026):

@rekram1-node I was having this issue and I created a draft PR that right now fixes it like 60% of the time https://github.com/anomalyco/opencode/pull/6883 (not 100% cuz I stopped when I saw a similar issue was closed). happy to move it forward if there is interest and alignment in the fix this way :)

@ramarivera commented on GitHub (Jan 4, 2026): @rekram1-node I was having this issue and I created a draft PR that right now fixes it like 60% of the time https://github.com/anomalyco/opencode/pull/6883 (not 100% cuz I stopped when I saw a similar issue was closed). happy to move it forward if there is interest and alignment in the fix this way :)
Author
Owner

@ramarivera commented on GitHub (Jan 4, 2026):

So as per @rekram1-node , the fix is not correct

@ramarivera commented on GitHub (Jan 4, 2026): So as per @rekram1-node , the fix is not correct
Author
Owner

@greggh commented on GitHub (Jan 7, 2026):

anyway u could share a session this happened?

opencode export > session.json

Sorry for the delay, got busy. Here is a log of a session I did yesterday just to attempt to get it to break the same way it is for some of us. I exported the session right after it had the error, so its in the last message. I had it just playing around with my GitHub skill.

ses_46b95350fffeq8T95l1hKVHwsM.md

@greggh commented on GitHub (Jan 7, 2026): > anyway u could share a session this happened? > > opencode export > session.json Sorry for the delay, got busy. Here is a log of a session I did yesterday just to attempt to get it to break the same way it is for some of us. I exported the session right after it had the error, so its in the last message. I had it just playing around with my GitHub skill. [ses_46b95350fffeq8T95l1hKVHwsM.md](https://github.com/user-attachments/files/24482737/ses_46b95350fffeq8T95l1hKVHwsM.md)
Author
Owner

@greggh commented on GitHub (Jan 10, 2026):

How is this going for others? I am still having the issue, but not as often. Maybe a 20% decrease in the amount of these errors since I reported it.

@greggh commented on GitHub (Jan 10, 2026): How is this going for others? I am still having the issue, but not as often. Maybe a 20% decrease in the amount of these errors since I reported it.
Author
Owner

@rickross commented on GitHub (Jan 10, 2026):

anyway u could share a session this happened?

opencode export > session.json

Do you need more session examples of this bug occurring, @rekram1-node ?

It has been happening to me, and I haven't yet figured out how to get out of it.

GLM-thinking-tools-errors.md

@rickross commented on GitHub (Jan 10, 2026): > anyway u could share a session this happened? > > opencode export > session.json Do you need more session examples of this bug occurring, @rekram1-node ? It has been happening to me, and I haven't yet figured out how to get out of it. [GLM-thinking-tools-errors.md](https://github.com/user-attachments/files/24545633/GLM-thinking-tools-errors.md)
Author
Owner

@autistarum commented on GitHub (Jan 10, 2026):

I think the issue in general with GLM 4.7 is that around 55-60%, e.g. >100K it degenerates, becomes confused and renders useless. It does not limit to tool use, it forgets the whole project context at the times, instructions, etc. and so far this behavior has been consistent for all my sessions. Granted, I only have had a few session with this model so far but this certainly does not look good.

@autistarum commented on GitHub (Jan 10, 2026): I think the issue in general with GLM 4.7 is that around 55-60%, e.g. >100K it degenerates, becomes confused and renders useless. It does not limit to tool use, it forgets the whole project context at the times, instructions, etc. and so far this behavior has been consistent for all my sessions. Granted, I only have had a few session with this model so far but this certainly does not look good.
Author
Owner

@rekram1-node commented on GitHub (Jan 10, 2026):

@rickross can u send the actual export using the command I sent? You just sent a markdown transcript, I need json exports using the command I attached

@rekram1-node commented on GitHub (Jan 10, 2026): @rickross can u send the actual export using the command I sent? You just sent a markdown transcript, I need json exports using the command I attached
Author
Owner

@rickross commented on GitHub (Jan 10, 2026):

@rickross can u send the actual export using the command I sent? You just sent a markdown transcript, I need json exports using the command I attached

I'm sorry @rekram1-node but that session is no longer available. If I see it again I will capture that way forr you. Thanks for looking into this.

@rickross commented on GitHub (Jan 10, 2026): > [@rickross](https://github.com/rickross) can u send the actual export using the command I sent? You just sent a markdown transcript, I need json exports using the command I attached I'm sorry @rekram1-node but that session is no longer available. If I see it again I will capture that way forr you. Thanks for looking into this.
Author
Owner

@LegendEvent commented on GitHub (Jan 27, 2026):

how consistent is this?

this is about 120-130k context. Only then this appears

@LegendEvent commented on GitHub (Jan 27, 2026): > how consistent is this? this is about 120-130k context. Only then this appears
Author
Owner

@greggh commented on GitHub (Jan 27, 2026):

how consistent is this?

this is about 120-130k context. Only then this appears

This is the same for me.

@greggh commented on GitHub (Jan 27, 2026): > > how consistent is this? > > this is about 120-130k context. Only then this appears This is the same for me.
Author
Owner

@LegendEvent commented on GitHub (Jan 28, 2026):

Did anyone checked if this also happens in any other agentic coding Environment besides opencode? I guess this is not a opencode only problem. I think this is an problem within the model itself. Fastes workaround is to set the Context lenght to 128000 instead of 200000

@LegendEvent commented on GitHub (Jan 28, 2026): Did anyone checked if this also happens in any other agentic coding Environment besides opencode? I guess this is not a opencode only problem. I think this is an problem within the model itself. Fastes workaround is to set the Context lenght to 128000 instead of 200000
Author
Owner

@greggh commented on GitHub (Jan 28, 2026):

Did anyone checked if this also happens in any other agentic coding Environment besides opencode? I guess this is not a opencode only problem. I think this is an problem within the model itself. Fastes workaround is to set the Context lenght to 128000 instead of 200000

This is also happening on other models in OpenCode, like Kimi K2.

@greggh commented on GitHub (Jan 28, 2026): > Did anyone checked if this also happens in any other agentic coding Environment besides opencode? I guess this is not a opencode only problem. I think this is an problem within the model itself. Fastes workaround is to set the Context lenght to 128000 instead of 200000 This is also happening on other models in OpenCode, like Kimi K2.
Author
Owner

@bdwelle commented on GitHub (Feb 5, 2026):

I'm getting the same thing, e.g.

Thinking: bash<arg_key>command</arg_key><arg_value>./split-mbox-emails.py 1-to-split/*.mbox 2>&1 | head -10</arg_value><arg_key>description</arg_key><arg_value>Test split script on glob pattern</arg_value></tool_call>

@bdwelle commented on GitHub (Feb 5, 2026): I'm getting the same thing, e.g. `Thinking: bash<arg_key>command</arg_key><arg_value>./split-mbox-emails.py 1-to-split/*.mbox 2>&1 | head -10</arg_value><arg_key>description</arg_key><arg_value>Test split script on glob pattern</arg_value></tool_call>`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4114