anomalyco / anomalyco/opencode

Agent loop runs 500+ steps with zero user input — no guard against runaway auto-continue

Open
#49,042 1 comment 0 reactions 1 assignee View on GitHub

@neriousy is already working on this.

Since Sep 14, 2026.

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

Description

Environment
  • opencode TUI, Linux, custom OpenAI-compatible provider (@ai-sdk/openai-compatible → koa-proxy → z.ai GLM-5.2).
  • Session storage: ~/.local/share/opencode/opencode.db (SQLite).
What happens

The agent loop auto-continues indefinitely after the model produces its final text response. Two sessions on 2026-09-14:

Session Loop steps user msgs (tail) assistant msgs Output tokens
ses_f5ea9de7bffeoBkzj24EyMMa3g ("Investigar conversación de bot en Chatwoot") 525 (66 min) 0 in the final 18 min 228 in the tail 53,572
ses_f5eab63c5ffeeuWv40uF3CZ9Zo 310 5 total (real human inputs) 310 34,599

Log signature: message=loop session.id=… step=N incrementing every ~5 s with no interleaved user activity. All messages share one parentID (the last real user message). The model's outputs in the runaway tail are minimal closings ("(fin)", "🤘", "·") — i.e. the model DID produce text-only terminal responses, but the loop kept stepping instead of ending the turn.

A contributing trigger observed with reasoning models: GLM-5.2 sometimes returns reasoning_content with empty content; opencode logs a placeholder _(reasoning-only response — model emitted no final text)_ and re-prompts. But the runaway also occurs after normal text responses, so the missing piece is a loop guard, not just empty-output handling.

Expected

After an assistant turn with no tool calls and no user input, the loop should end. At minimum: a guard that halts after N consecutive steps without human input or tool activity, surfacing "possible runaway loop — press Enter to continue".

Why doom_loop doesn't catch it

doom_loop permission triggers only on the same tool call repeating 3× with identical input. Text-only runaway has no tool calls at all — no knob covers it.

Repro
  1. Use a reasoning-capable model via OpenAI-compatible provider that occasionally returns empty content.
  2. Let a task complete; observe step=N climbing in the logs with no input.
  3. Loop sustains itself for hours until manually interrupted (Esc).
Workaround

Esc / close session. A pending question tool call also parks the loop (it blocks awaiting real input).

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.