anomalyco / anomalyco/opencode
Failed tool execution can leave plugin state permanently orphaned because tool.execute.after never fires
@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
- Install the oh-my-opencode-slim plugin.
- 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.
- Configure the proxy to continuously return HTTP 503 for /v1/responses and /v1/chat/completions when a flag is enabled.
- Start OpenCode and launch a foreground fixer task.
- Wait for it to complete and become reusable.
- Enable continuous 503 injection, then resume the same fixer using its existing task_id.
- Wait for the provider retries to be exhausted, then disable the injection.
- Observe that tool.execute.before was emitted and the child session transitioned busy → idle, but no matching tool.execute.after was emitted.
- Resume the same task_id again. It fails with:
its current generation is already owned by another lifecycle operation - Attempt task_revive; it fails with:
relaunch lease unavailable - 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
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.