test: add tests for plugin tool execution hooks #7211

Closed
opened 2026-02-16 18:06:28 -05:00 by yindo · 1 comment
Owner

Originally created by @kynnyhsap on GitHub (Jan 22, 2026).

Originally assigned to: @rekram1-node on GitHub.

Summary

The tool.execute.before and tool.execute.after plugin hooks lack test coverage. These hooks are critical for plugin developers who want to intercept and modify tool executions.

Problem

Currently, there are no automated tests verifying:

  • Hooks receive correct input parameters
  • Hooks can modify tool arguments (before) and results (after)
  • Hooks can throw to block execution (before)
  • Multiple hooks are called sequentially
  • Edge cases like no hooks registered

Solution

Add comprehensive tests for both hooks covering all use cases.

Files to add

  • packages/opencode/test/plugin/tool-hooks.test.ts
Originally created by @kynnyhsap on GitHub (Jan 22, 2026). Originally assigned to: @rekram1-node on GitHub. ## Summary The `tool.execute.before` and `tool.execute.after` plugin hooks lack test coverage. These hooks are critical for plugin developers who want to intercept and modify tool executions. ## Problem Currently, there are no automated tests verifying: - Hooks receive correct input parameters - Hooks can modify tool arguments (`before`) and results (`after`) - Hooks can throw to block execution (`before`) - Multiple hooks are called sequentially - Edge cases like no hooks registered ## Solution Add comprehensive tests for both hooks covering all use cases. ## Files to add - `packages/opencode/test/plugin/tool-hooks.test.ts`
yindo closed this issue 2026-02-16 18:06:28 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 22, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #5894: [BUG] Plugin hooks (tool.execute.before) don't intercept subagent tool calls - security policy bypass
  • #9056: [FEATURE]: Expose tool execution capabilities to plugins
  • #10027: [FEATURE]: add tool.execute.error hook to handle tool call errors

These issues are related to plugin tool execution hooks and may share overlapping test coverage requirements or expose related functionality gaps that should be considered when adding tests.

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 22, 2026): This issue might be a duplicate of existing issues. Please check: - #5894: [BUG] Plugin hooks (tool.execute.before) don't intercept subagent tool calls - security policy bypass - #9056: [FEATURE]: Expose tool execution capabilities to plugins - #10027: [FEATURE]: add `tool.execute.error` hook to handle tool call errors These issues are related to plugin tool execution hooks and may share overlapping test coverage requirements or expose related functionality gaps that should be considered when adding tests. Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7211