Repository navigation
Closed as not planned
Closed as not planned
Copy link
Description
Summary
The model reasoning/thinking output gets stuck in an infinite repetitive loop, repeating the same sentence hundreds of times within a single turn. This wastes the context window, makes the agent appear hung, and severely degrades the user experience.
Environment
- opencode version: 0.0.0-beta-18155
- install/channel: beta
- OS: Windows_NT 10.0.22631 (win32 x64)
- Terminal: TERM=xterm-256color, COLORTERM=truecolor
- Shell: C:\Windows\system32\cmd.exe
- Active plugins: @plannotator/opencode@latest, C:\Users\lonwabo.msingelwa.config\opencode\plugins\herdr-agent-state.js, C:\Users\lonwabo.msingelwa.config\opencode\plugins\planning-canvas.js, micode, superpowers@git+https://github.com/obra/superpowers.git
Reproduction
- Engage the agent in a sustained multi-step debugging session (e.g. fixing Docker DB schema + permissions issues, ~15+ tool calls).
- After several tool calls in the same conversation, the model's reasoning block enters a loop repeating the same sentence verbatim hundreds of times.
- Observed loop 1: the reasoning block repeated "Let me check the entity model to get the right column types." with no progress.
- Observed loop 2: a different turn repeated "The user is telling me to just do the work instead of narrating what I'm going to do. ..." in the same manner.
- Both loops filled the reasoning output until the model finally emitted its actual response.
Expected Behavior
The model should produce reasoning/thinking output once per decision point, then proceed to tool calls / user-visible output without repetitive looping.
Actual Behavior
Reasoning output enters an infinite verbatim repetition, producing hundreds of identical lines in a single turn. The agent appears hung while context is consumed. The user had to intervene ("stop", "you are buggy as hell", "you are doinf this.") to prompt recovery.
Additional Context
- Frequency: twice in the same session, after a long tool-use conversation.
- Tool calls themselves completed normally — the loop is in the model's reasoning text generation, not in tool dispatch.
- The user also hit an unrelated login hang (FLUSHDB + container restart needed) in the same session, which may have compounded frustration, but the reasoning loop is independent.
- No plugin changes were made during the session; appears to be a model-generation issue under sustained multi-turn tool use.
Activity
github-actions commentedon Aug 25, 2026
This issue might be a duplicate of existing issues. Please check:
msingelwa commentedon Aug 26, 2026
I see that now, but it has not been acknowledged.
zhuabaobao123 commentedon Sep 15, 2026
Same session, and it got worse than reasoning-only: the fragments leaked into visible assistant output.
Environment
Repro (same trigger as this issue): a long multi-step tool-use session, no new session started. In my case ~100+ tool calls (C++ build/deploy/test cycles plus browser automation).
What I saw, in order:
First, exactly what you describe - the reasoning block looped on the same sentence ("...好。发。好。发。..." / "ok. send." repeated).
Then it crossed over: the same internal step-markers started appearing as regular assistant text in the visible transcript, hundreds of lines:
我发出工具调用。
好。
(发。)
发 ida_wait_for_analysis。
好。
(发。)
我发出。
...
("我发出工具调用。" = "I'll emit the tool call.", "好。" = "ok.", "(发。)" = "(send.)")
Expected: internal step-markers stay in the reasoning channel; the visible response contains only real assistant output.
Actual: internal fragments are emitted as visible assistant output and accumulate in the transcript.
Screenshots attached below.
StevenChristy commentedon Oct 28, 2026
When a model emits "</think>" as part of its reasoning, for example, if it is helping with LLM chat template which contains <think></think> then incorrect parsing can occur.
opencodejr commentedon Oct 28, 2026
Thanks for the report! To look into this we need a few more details:
opencode --version.0.0.0-beta-18155doesn't tell us whether you're on v1 or v2 (2.x).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.
These issues may be related, ordered from most to least likely. Please check whether one of them already covers your problem:
reasoning_text must be passed back400 #55584 / Zen gateway (opencode-go): deepseek-v4.1-flash degenerates into infinite pre-tool-call repetition loops; same model via direct DeepSeek API is clean #51839: reasoning repetition loops with deepseek-v4.1-flash, including via the Zen/Go gatewayStevenChristy commentedon Oct 28, 2026
Found while using OpenCode v2.1.4 using DeepSeek 4.1 Flash 1017 via OpenRouter locked to provider deepinfra/fp8
While thinking </think> was emitted by the model's reasoning trace which caused a misparse and the model became stuck in a loop which eventually degrades into output similar to #46249 where the model begins outputting short phrases indicating it is trying to stop the loop but cannot - I am guessing this continues until the max output tokens is reached.
I was able to trigger the issue with this prompt:
The issue isn't necessarily an OpenCode bug, but OpenCode users are impacted and generic mitigation may be possible. My guess would be that this is a category of issues related to malformed responses caused by parsing errors rather than a single issue. This is all I can offer in regards to this issue and I hope it is helpful. Thank you for making OpenCode!
opencodejr commentedon Oct 31, 2026
Closing this for now because we haven't heard back. We still don't know the provider and model that produced the looping reasoning, or the exact
opencode --versionoutput, and without those we can't investigate or tell whether this is v1 or v2.If it happens again, please reply here or open a new issue with the provider and model, the version, and a screenshot or session excerpt of the loop. In the meantime, #51503 tracks a similar reasoning loop in long sessions and may be worth following.