You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Let tool.execute.before short-circuit a tool call with a substitute result #32565
tool.execute.before can mutate a tool's args but can't stop the tool from running, and tool.execute.after only rewrites the result after it ran. There's no way for a plugin to answer a tool call itself and skip execution.
The runtime always runs the tool after the before-hook (packages/opencode/src/session/tools.ts, native path ~L88–93 and MCP path ~L129–139): it triggers tool.execute.before, then unconditionally calls item.execute(...).
Use case: a memory/cache plugin that already holds the answer for a read/grep (an indexed summary or cached result) and wants to return it instead of doing the read. Today it can only let the read happen and prepend a note in tool.execute.after, so the unnecessary work still runs. permission.ask can deny a call but returns an error, not a substitute result.
Proposal
Let tool.execute.before optionally supply a result and/or skip execution:
After the trigger, if skip is set (or result is provided), build the standard output from result and bypass item.execute(...). Backwards compatible — hooks that set neither behave exactly as today. The native and MCP paths return slightly different output shapes, so the substitute would need handling in both.
Alternatives
tool.execute.after banner — the tool still runs.
permission.ask deny — blocks, but yields an error rather than a clean result.
Happy to open a PR if this seems reasonable. Wanted to check the approach first per the contributing guide.
Activity
github-actions commentedon Jun 16, 2026
This issue doesn't fully meet our contributing guidelines.
What needs to be fixed:
[FEATURE]:(e.g.,[FEATURE]: Let tool.execute.before short-circuit a tool call with a substitute result)Please edit this issue to address the above within 2 hours, or it will be automatically closed.
This issue might be a duplicate of existing issues. Please check:
If you believe this was flagged incorrectly, please let a maintainer know.
github-actions commentedon Jun 16, 2026
This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.
Feel free to open a new issue that follows our issue templates.