anomalyco / anomalyco/opencode

Failed tool execution can leave plugin state permanently orphaned because tool.execute.after never fires

Open
#48,085 1 comment 0 reactions 1 assignee View on GitHub

@rekram1-node is already working on this.

Since Sep 9, 2026.

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

Description

Description

A model/API error during a task invocation can leave a plugin without a matching settlement hook.

In my case:
tool.execute.before
→ resumed child session becomes busy
→ model API request errors
→ child session returns to idle
→ no matching tool.execute.after

The plugin had acquired a relaunch lease in tool.execute.before, so the missing settlement event left that lease orphaned. Subsequent attempts to resume the same task failed until OpenCode was restarted.
Related to #27900

Could OpenCode provide a failure-side settlement hook, e.g. an optional tool.execute.error, while keeping the current success-only semantics of tool.execute.after?
success: before → after
failure: before → error

Plugins

No response

OpenCode version

No response

Steps to reproduce
  1. Install the oh-my-opencode-slim plugin.
  2. Configure only the fixer agent to use a model endpoint routed through a reverse proxy (such as mitmproxy); keep the orchestrator on the normal endpoint.
  3. Configure the proxy to continuously return HTTP 503 for /v1/responses and /v1/chat/completions when a flag is enabled.
  4. Start OpenCode and launch a foreground fixer task.
  5. Wait for it to complete and become reusable.
  6. Enable continuous 503 injection, then resume the same fixer using its existing task_id.
  7. Wait for the provider retries to be exhausted, then disable the injection.
  8. Observe that tool.execute.before was emitted and the child session transitioned busy → idle, but no matching tool.execute.after was emitted.
  9. Resume the same task_id again. It fails with:
    its current generation is already owned by another lifecycle operation
  10. Attempt task_revive; it fails with:
    relaunch lease unavailable
  11. Restart OpenCode and resume the same underlying ses_* session. It succeeds, confirming that restart cleared the stale lifecycle ownership.
    The failing resume must be foreground. With background: true, the task invocation returns immediately and receives tool.execute.after before the child model request fails.

You can copy this bug description and steps of reproducing to an opencode session and it will help you to reproduce this bug.

Screenshot and/or share link

No response

Operating System

windows 11 WSL2 Ubuntu 22.04.2 LTS

Terminal

No response

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.