Skip to content

gemini "i'm finished" loop #262

Closed
Closed

Description

@adamdotdevin
No description provided.

Activity

  1. nefthy commented on Jun 21, 2025

    @nefthy

    I can confirm. I get an endlessly repeating stream of messages like:
    he build was successful. I have implemented the logic to show and hide the "No cards yet" message. The build was  successful. I have implemented the logic to show and hide the  "No cards yet" message. The build was successful.

  2. unkhz commented on Jun 24, 2025

    @unkhz
    Contributor

    Been trying this out for a few days. Endless loop happening with local models very often for me. I've been experimenting only with self hosted models (lm studio) and they rarely get past the first task without ending up in a loop. Some examples of models I've tried

    • qwen/qwen3-30b-a3b
    • deepseek-coder-33b-instruct-hf-mlx
    • mistralai/devstral-small-2505

    A workaround seems to be adding "just do it, don't ask for permission" in the end of the prompt, in which case it can do more than one thing, since it'll not stop for more input.

    Image

    current config

    {
      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "lmstudio": {
          "npm": "@ai-sdk/openai-compatible",
          "options": {
            "baseURL": "http://localhost:8080/v1"
          },
          "models": {
            "qwen/qwen3-30b-a3b": {
              "limit": { "context": 131072, "output": 1000000 }
            },
            "mistralai/devstral-small-2505": {
              "limit": { "context": 131072, "output": 1000000 }
            }
          }
        }
      }
    }
    
  3. unkhz commented on Jun 24, 2025

    @unkhz
    Contributor

    Ok, seems I've shot myself in the foot with the output limit. Changed the output tokens from 1000000 to 4096 and I'm not seeing this anymore. Tried both models in above config and they work as expected.

    However I think there's a condition where this infinite repetition occurs even without absurd output limit. Seems the absurd output limit is the easiest way to reproduce it. I'm thinking it's related to the summarization logic, which recurses back to the chat based on comparing the limits to current token count: https://github.com/sst/opencode/blob/9cfb6ff9646553d6dcbcbe22844ffbeb6480dc12/packages/opencode/src/session/index.ts#L280-L299

    Might be something I could attempt creating a fix for.

  4. unkhz commented on Jun 26, 2025

    @unkhz
    Contributor

    The first PR was pretty much a cosmetic sanity check. I think the larger problem is getting into a situation where summary accompanied with input and cache reads/writes grows larger than 90% of the token limit, eventually causing this infinite loop. This is a real consideration for small local models, but not so much for the $$$ models.

    One option is to take control of the summary size. We possibly can use maxTokens parameter of streamText to limit to certain size and then take the last summary size into account (and even when it was last run) when deciding "should I run auto summarize again?". A more robust logic like this might do the trick of getting rid of this problem for real.

  5. rekram1-node commented on Dec 28, 2025

    @rekram1-node
    Contributor

    [automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!

  6. added a commit that references this issue on Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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