Repository navigation
Open
Labels
Description
Description
Description
In a long-running session, the assistant repeatedly re-emits the same block of
text and/or re-issues the same tool call with identical arguments, without making
any progress. The repetition does not terminate on its own; it only stops when the
model reaches the provider's max output tokens, leaving the turn truncated. The
only way to continue is to abort and re-prompt.
This happened several times within a single session. It affects both plain-text
assistant output and tool-call sequences (the same tool, same arguments, repeated
back to back).
Environment
- opencode
2.1.4(update to2.2.0offered at the time of the report) - OS: Windows 11, build
10.0.26200.9711 - Terminal: Windows Terminal (
WT_SESSIONset),TERM=xterm-256color - Shell: PowerShell
5.1.26100.9711 - Provider: custom,
@ai-sdk/anthropic(Anthropic-compatible endpoint) - Model:
deepseek-v4.1-flash-1017 - Plugin:
superpowers(loaded from a local directory) - Session shape: one long session, 100+ tool calls, several large file reads and
long tool outputs
Steps to reproduce
- On Windows, start a long session that performs many sequential tool calls,
including large file reads and long tool outputs. - Ask for a series of small edits and verifications spread over several files.
- After a number of turns, the assistant begins repeating an identical paragraph,
or re-issuing an identical tool call with identical arguments. - Observe that the repetition never resolves by itself; the turn ends only when
the output token limit is reached.
Expected behaviour
- The assistant finishes the step, then either calls the next tool or ends the turn.
- A run of identical tool invocations (same tool name + same arguments) whose
results have not changed should be detected and broken out of, ideally with a
visible warning, instead of silently consuming the whole output budget.
Actual behaviour
- Identical text blocks and identical tool calls repeat many times inside one
assistant message until the output budget is exhausted. - The turn is left truncated mid-step, so the user has to abort manually.
- Nothing is written to
opencode.log: the log contains onlyspawning process
entries for the tool calls, with no finish reason, no output token count, and no
truncation marker. The failure is therefore invisible in diagnostics.
Impact
- Blocks progress: the session cannot continue without a manual abort.
- Each occurrence burns a full output budget in tokens, time and cost.
- Hard to triage: no trace in the log, and the behaviour is not tied to a single
tool, so it is not obvious which layer (model provider, streaming, or agent loop)
is responsible.
Additional context / suggestions
- Log finish reason (
stop/length/abort) plus output token counts per
assistant message, so output-limit truncation is diagnosable after the fact. - Consider a guard in the agent loop for N consecutive identical tool invocations
(same name + same arguments) or near-identical repeated text within a single
assistant message; cut the stream and surface a warning instead of letting it run
to the token limit. - It is unclear whether the root cause is provider-side (repeated sampling) or the
client re-sending/merging streamed parts incorrectly; the missing finish-reason
logging makes it impossible to tell from the outside.
Plugins
No response
OpenCode version
No response
Steps to reproduce
No response
Screenshot
No response
Operating System
No response
Terminal
No response
Activity
opencode-agent commentedon Oct 27, 2026
Thanks for the detailed report! I think this is a duplicate of #59339. v2 still accepts the
doom_looppermission action, but nothing in v2 currently triggers it. So when the model falls into a repetition loop, nothing stops it, and it keeps going until the output limit.Possible duplicates and closely related issues, ordered by likelihood:
doom_loop, so repeated identical tool calls run indefinitely. It includes a proposal for detectors, which is the guard you suggest.Your other suggestions (detecting repeated text within a message, and logging finish reason and output tokens per message) would fit well as comments on #59339.
The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.