#18559 · @kldzj · opened Mar 21, 2026 at 10:01 PM UTC · last updated Mar 21, 2026 at 10:02 PM UTC
feat(plugin): add cancellation support for `command.execute.before` hook
Score breakdown
Impact
Clarity
Urgency
Ease Of Review
Guidelines
Readiness
Size
Trust
Traction
Summary
This PR introduces a cancelled boolean to the command.execute.before hook output, enabling plugins to cleanly prevent subsequent LLM invocation. This change resolves a critical user experience issue where plugin command cancellations previously resulted in a 500 error in the web app.
Description
Issue for this PR
Closes #18554 and #9306
Type of change
- [ ] Bug fix
- [x] New feature
- [ ] Refactor / code improvement
- [ ] Documentation
What does this PR do?
Adds a cancelled boolean to the command.execute.before hook output type. Plugins can set output.cancelled = true to prevent the subsequent prompt() call and Command.Event.Executed publish from running.
Previously the only way to prevent LLM invocation from a plugin was to throw, which surfaced as a 500 in the web app. Now the hook can cleanly signal cancellation via the same mutable-output pattern every other hook already uses.
How did you verify your code works?
Reviewed all callers of SessionPrompt.command() to confirm they handle undefined returns.
Checklist
- [x] I have tested my changes locally
- [x] I have not included unrelated changes in this PR
Linked Issues
#18554 [FEATURE]: Add cancellation support for `command.execute.before` hook
View issueComments
No comments.
Changed Files
packages/opencode/src/server/routes/session.ts
+1−0packages/opencode/src/session/prompt.ts
+4−2packages/plugin/src/index.ts
+1−1