anomalyco / anomalyco/opencode
Loop exits silently on orphaned interrupted tool — prompt stays unanswered
@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
opencoderetries; retried request completes with emptyfinish: "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 astool_resultso model cannot self-correct.
Root cause:
packages/opencode/src/session/processor.ts:cleanup()force-marks abandoned tool asinterrupted:truepackages/opencode/src/session/prompt.tsexcludes orphaned interrupted tools fromhasToolCalls→ 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.