Skip to content

GLM-4.6 model gets stuck in infinite loop, repeating same actions #3444

Closed

Description

@ElecTwix

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:

  1. Use opencode with GLM-4.6 model (via z.ai plan provider)
  2. Give a moderately complex task that requires multiple steps
  3. Observe that the agent starts repeating the same tool calls or actions
  4. 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.

Image Image

Activity

  1. github-actions commented on Oct 25, 2025

    @github-actions
    Contributor

    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.

  2. rekram1-node commented on Oct 25, 2025

    @rekram1-node
    Collaborator

    @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

  3. rekram1-node commented on Oct 30, 2025

    @rekram1-node
    Collaborator

    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

  4. betolink commented on Dec 22, 2025

    @betolink

    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?

  5. TrentBrown commented on Jan 6, 2026

    @TrentBrown

    This just happened to me twice today. The model was endlessly executing git commands in one case.

  6. StarkBotha commented on Mar 25, 2026

    @StarkBotha

    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

  7. robotajet commented on Mar 30, 2026

    @robotajet

    It seems it mainly is affecting opencode-cli not the app (I cannot get it to go into an endless loop on the app)

  8. gintasz commented on Apr 4, 2026

    @gintasz

    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

    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 :

      "provider": {
        "openrouter": {
          "models": {
            "xiaomi/mimo-v2-pro": {
              "options": {
                "frequency_penalty": 0.3
              }
            }
          }
        }
      }
    

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions