You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GLM-4.6 model gets stuck in infinite loop, repeating same actions #3444
When using the GLM-4.6 model with opencode, the agent sometimes gets stuck in an infinite loop where it performs the same actions repeatedly instead of progressing through the task. This behavior doesn't occur with Claude Code or other models.
Steps to reproduce:
Use opencode with GLM-4.6 model (via z.ai plan provider)
Give a moderately complex task that requires multiple steps
Observe that the agent starts repeating the same tool calls or actions
The agent continues this loop indefinitely without completing the task
Expected behavior:
The agent should progress through the task logically, completing each step and moving to the next one, similar to how Claude Code behaves.
Actual behavior:
The GLM-4.6 model gets stuck repeating the same actions in a loop, never progressing to complete the task.
Environment:
Model: GLM-4.6 (z.ai plan provider)
Other models work fine (Claude Code, etc.)
Additional context:
This appears to be specific to the GLM-4.6 model's behavior or how it processes the opencode tool system. The issue doesn't occur with other models, suggesting it's not a general opencode bug but rather a model-specific interaction problem.
While these issues involve different models or specific scenarios, they all share the common pattern of models getting stuck in repetitive loops instead of progressing through tasks. The GLM-4.6 specific behavior you're experiencing may be related to how this model handles tool calling or task progression in the opencode environment.
Feel free to ignore if none of these address your specific case.
@ElecTwix yeah some models like glm 4.6 and grok code get into these doom loops, I heard things like kilo code have loop detection to help prevent this, I think we may wanna add something similar to be more defensive for the user
This is just the model being dumb, it can happen regardless of harness but we should yeah detect and try to prevent if we can
Reacted by Ahmet Çetinkaya, Agung Bahtiar, dkx, Vlad Vladov and psic4t
Note for future, if anyone sees this behavior again just provide the example and we can improve the doom loop detection to try to handle more cases, right now we made a dumb but useful detection but it can be a bit smarter in the future if need be
I just ran into this with GLM 4.7, I read that there is a PR that got merged to detect this infinite loops but at least in this case it didn't work. Is this a model or an opencode issue?
Activity
github-actions commentedon Oct 25, 2025
This issue might be a duplicate of existing issues. Please check:
While these issues involve different models or specific scenarios, they all share the common pattern of models getting stuck in repetitive loops instead of progressing through tasks. The GLM-4.6 specific behavior you're experiencing may be related to how this model handles tool calling or task progression in the opencode environment.
Feel free to ignore if none of these address your specific case.
rekram1-node commentedon Oct 25, 2025
@ElecTwix yeah some models like glm 4.6 and grok code get into these doom loops, I heard things like kilo code have loop detection to help prevent this, I think we may wanna add something similar to be more defensive for the user
This is just the model being dumb, it can happen regardless of harness but we should yeah detect and try to prevent if we can
rekram1-node commentedon Oct 30, 2025
Note for future, if anyone sees this behavior again just provide the example and we can improve the doom loop detection to try to handle more cases, right now we made a dumb but useful detection but it can be a bit smarter in the future if need be
betolink commentedon Dec 22, 2025
I just ran into this with GLM 4.7, I read that there is a PR that got merged to detect this infinite loops but at least in this case it didn't work. Is this a model or an opencode issue?
TrentBrown commentedon Jan 6, 2026
This just happened to me twice today. The model was endlessly executing git commands in one case.
StarkBotha commentedon Mar 25, 2026
This is not just GLM. It on MiMo-V2-Pro as well as MiniMax M2.7. Its not a model issue its an OpenCode bug
robotajet commentedon Mar 30, 2026
It seems it mainly is affecting opencode-cli not the app (I cannot get it to go into an endless loop on the app)
gintasz commentedon Apr 4, 2026
I've had same issue on MiMo-V2-Pro on the very first try, I've added frequency penalty to opencode.json to see if that can help :
EDIT: I spent a few hours doing work with the model, the issue was never observed. So it's either working or it's a coincidence.