Skip to content

Loop doesn't exit after finish=stop — model re-invoked with no input until the session is quit #42576

Closed as not planned

Description

@Prathyushmnchla

Description

When the agent finishes a turn with finish=stop and no tool calls, the session should go idle. Instead the loop keeps running and re-calls the model every ~10-20s with no new user message. The UI shows "busy" the whole time while the model just returns one-line filler ("Standing by", "Ready", "Idle").

From the logs:

  • Normal cycles end with an exiting loop event. The stuck cycle never emits one — it runs loop step=0..28+ over ~25 minutes.
  • The repeating pattern is loop step=N -> process (new message) -> stream (new model call), with nothing in between.
  • Every filler message is finish=stop and its step-finish reason=stop, so the model is correctly signaling "done" and the loop is ignoring it.
  • Esc fires cancel + error=Aborted (finish=None, 0 parts), then the loop restarts at step=0 and sticks again. Esc doesn't break it; only quitting the session does.

Also notable: the model's hidden reasoning in those filler turns literally says "I'm being repeatedly prompted with no user message — this is an artifact", so it's aware it's being re-called with nothing to do.

Version 1.17.18, model deepseek-v4-pro (opencode-go), Linux/WSL. Reproduced in one session, then again right after resuming it. Looks related to #42363 and #22329.

Plugins

No plugins

OpenCode version

1.17.18

Steps to reproduce

  1. Run opencode (v1.17.18) with deepseek-v4-pro (opencode-go).
  2. Do a normal multi-turn agent task — several tool calls, some reasoning, then a finish=stop (e.g. "implement X, run the tests, commit, summarize").
  3. Let it reach a turn that ends with no tool calls. Instead of going idle, it keeps re-calling the model every ~10-20s with no new input — the UI stays "busy" and it appends one-line "Standing by" / "Ready" / "Idle" replies.
  4. Press Esc: the current generation aborts, but the loop restarts at step=0 and sticks again.
  5. Only quitting the session (Ctrl+C) stops it.
    Note: not fully deterministic — I only hit it after long sessions with a lot of reasoning/tool history, so it may depend on context length.

Screenshot and/or share link

Recreated using sql db trace by ds4 pro

Image

Operating System

WSL on Windows 11

Terminal

westerm

Activity

  1. yazonets-maker commented on Aug 14, 2026

    @yazonets-maker

    opencode_loop_issue42576_excerptX.txt

    Reproduced on v1.18.4 (Windows, PowerShell), model deepseek-v4-pro via opencode-go.

    Details from my logs + opencode.db:

    • Loop ran 838 steps over ~3.5 hours; each cycle is loop step=N -> process -> stream
      with no new user message.
    • Every filler turn had zero tool calls; step-finish reason=stop on 825/826 messages.
      The very first loop message had reason=unknown (likely the trigger), after which
      the loop ignored every subsequent finish=stop.
    • Model's hidden reasoning literally said: "I'm in an infinite loop being prompted
      with no new user input".
    • The loop did NOT terminate on finish=stop; it stopped only when the provider returned
      AI_APICallError: Weekly usage limit reached.
    • Esc/cancel fired error=Aborted but did not break the loop; only quitting the session did.
    • Consequence: it consumed my entire weekly API quota.

    Happy to attach a full log excerpt if useful.

  2. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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