Skip to content

Loop exits silently on orphaned interrupted tool — prompt stays unanswered #44254

Closed as not planned

Description

@sujalmh

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)

Activity

  1. sujalmh commented on Aug 22, 2026

    @sujalmh
    Author
    1. Run a mock OpenAI-compatible provider that streams tool-input-start without complete tool-call then cuts connection mid-stream
    2. Configure opencode.json provider to point to the mock and drive opencode serve via HTTP API with a prompt that triggers a tool
    3. Mock cuts stream → opencode retries → retry returns empty finish: "stop"
    4. Observe WARN loop exit with orphaned interrupted tool + INFO exiting loop and persisted Tool execution aborted part with no assistant text; re-prompting continue still exits silently
  2. sujalmh commented on Aug 22, 2026

    @sujalmh
    Author

    OS: Linux (repro verified on 1.18.21), also macOS 15.x darwin
    Terminal: via opencode serve HTTP API (zsh / iTerm2)
    Plugins: any MCP tool (repro uses generic read)

  3. github-actions commented on Aug 22, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  4. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions