anomalyco / anomalyco/opencode

Loop exits silently on orphaned interrupted tool — prompt stays unanswered

Open
#44,254 3 comments 0 reactions 1 assignee View on GitHub

@nexxeln is already working on this.

Since Aug 22, 2026.

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

Description

When a tool call is cut mid-stream (provider emits tool-input-start without a complete tool-call then drops the connection), the agent loop silently exits without answering the prompt.

Repro:

  • Mock OpenAI-compatible provider that streams a tool announcement with incomplete arguments then cuts mid-stream
  • opencode retries; retried request completes with empty finish: "stop"
  • processor.cleanup() marks the in-flight tool as:
{"type":"tool","tool":"read","callID":"call_orphan_1","state":{"status":"error","input":{},"error":"Tool execution aborted","metadata":{"interrupted":true},"time":{"start":1787392868553,"end":1787392868553}}}
  • Run loop logs:
WARN loop exit with orphaned interrupted tool session.id=ses_... messageID=msg_... tool=read callID=call_orphan_1
INFO exiting loop session.id=ses_...
  • Persisted assistant message has no text, zero tokens, time.start == time.end. Prompt stays unanswered, no error surfaced, interrupted tool never fed back as tool_result so model cannot self-correct.

Root cause:

  • packages/opencode/src/session/processor.ts:cleanup() force-marks abandoned tool as interrupted:true
  • packages/opencode/src/session/prompt.ts excludes orphaned interrupted tools from hasToolCalls → message judged finished → loop breaks

Expected:
Treat interrupted:true as recoverable tool error: feed Tool execution aborted — please retry with complete arguments back as tool_result and retry (with limit), or after retries emit a user-visible assistant error. Never exit silently with zero tokens.

Also seen: short sessions (83 parts / 113k tokens) and stealth/oxalpha + muse-spark families; also step-finish reason:unknown with zero tokens after Service Unavailable on retry — same silent-exit family.

Verified on: opencode 1.18.21 Linux (and 1.3.13 macOS)

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.