anomalyco / anomalyco/opencode

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

Open
#42,576 1 comment 0 reactions 1 assignee View on GitHub

@kitlangton is already working on this.

Since Aug 14, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.