Skip to content

Bug: Session corrupted when tool execution is aborted - missing tool_result causes API rejection #755

@popododo0720

Description

@popododo0720

Summary

When a tool execution is aborted, the session becomes permanently corrupted. Subsequent messages fail with Anthropic API error: tool_use ids were found without tool_result blocks.

Steps to Reproduce

  1. Start a conversation that triggers tool calls
  2. Abort/cancel during tool execution
  3. Try to continue the conversation in the same session
  4. API returns error: messages.N: tool_use ids were found without tool_result blocks immediately after: toolu_XXXXX

Root Cause

When a tool is aborted, the tool call part is saved with status: "error" and error: "Tool execution aborted", but no corresponding tool_result message is created.

From the logs:

ERROR service=session.processor error=The operation was aborted. 
stack="abort@[native code]\ncancel@/$bunfs/root/src/cli/cmd/tui/worker.js:..."

The abort happens in oh-my-opencode's worker/session processor, but the tool_result is not properly returned to OpenCode.

Related

Impact

  • Session becomes unusable after any tool abort
  • User must start a new session, losing conversation context

I'd like to work on this fix. Happy to submit a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions