Skip to content

provider/streaming: reasoning degenerates into repetitive loop on long session #51503

Closed as not planned

Description

@eltPlay

Summary

In a long desktop session (heavy MCP tool usage while testing wincontrol desktop-control), the assistant's reasoning stream degenerated into a repetitive near-empty loop — dozens of consecutive lines of "好。", occasionally "我输出。", "(写)", "(执行)", "嗯。" — until the turn was abandoned. Possibly model-side behavior, but filing for triage since it coincided with compaction / MCP catalog changes in the session.

Environment

  • opencode version: 2.0.18
  • OS: Windows_NT 10.0.26200 (win32 x64), OpenCode Desktop app
  • Model: qwen3.8-flash (provider: alibaba-token-plan-cn, variant: xhigh)
  • Active plugins: @prevalentware/opencode-goal-plugin, local handoff-on-compact plugin (fires on context compaction)

Reproduction

  1. Run a long session with many tool calls against an MCP server (wincontrol), including an MCP server restart / tool-catalog change mid-session.
  2. Session grows long enough to trigger context compaction (handoff-on-compact plugin active).
  3. On a subsequent turn, the reasoning part degenerates into a repetitive loop of "好。" and similar filler tokens, continuing indefinitely.

Expected Behavior

Either coherent reasoning output, or the provider/stream erroring cleanly. Not an endless degenerate loop.

Actual Behavior

The reasoning section rendered dozens of repeated short lines ("好。好。我输出。好。嗯。好。好。(写)好。好。...") in the desktop UI. Screenshot held by reporter; can attach on request.

Additional Context

  • Uncertain whether this is an opencode bug (streaming/retry/compaction handling) or purely provider/model degeneration; happy to provide session JSON / logs if maintainers can tell which layer it belongs to.
  • The session also exhibited a separate transient issue (404 "Message not found" toast after revert + resubmit), filed separately.

Activity

  1. github-actions commented on Sep 26, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    • #44962: reports reasoning stuck in an infinite repetitive loop during a sustained multi-step session with many tool calls.
    • #33135: reports reasoning text repeating the same token indefinitely in some providers.
    • #41801: reports thousands of repeated lines during compaction in a long session.
  2. opencodejr commented on Oct 28, 2026

    @opencodejr

    Thanks for the detailed report, @eltPlay!

    A reasoning stream that keeps repeating short filler like 好。 is usually the model degenerating. OpenCode's built-in loop detection (doom_loop) only catches repeated identical tool calls, not repeated text. To tell whether OpenCode is involved (for example, a broken context sent to the model after compaction or the MCP tool-catalog change), could you share:

    1. The session export for the affected session (opencode export <sessionID>, or the session JSON you mentioned). Please remove anything sensitive first. The parts we most need are the compaction summary and the messages just before the looping turn.
    2. The screenshot of the looping reasoning.
    3. Whether it happens again: does the same session or prompt loop again with a different model, or with the local handoff-on-compact plugin disabled? Does it only happen after compaction, or also in fresh sessions with qwen3.8-flash at xhigh?
    4. Logs from around that turn, if you have them, especially any provider errors or retries.

    You can reply here with the details, or edit the issue. If you edit it, please also leave a comment saying you've updated it so we know you're done.

  3. opencodejr commented on Oct 31, 2026

    @opencodejr

    Closing this for now, since we didn't get the details needed to look into it: the session export (especially the compaction summary and the messages before the looping turn), the screenshot, or whether the loop happens again with another model or with the handoff-on-compact plugin disabled. Without these we can't tell whether OpenCode sent a broken context or whether the model (qwen3.8-flash at xhigh) degenerated on its own.

    Thanks for reporting it, @eltPlay! If it happens again, please reply here with those details or open a new issue, and we'll take another look.

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions