refactor: centralize tool plugin hooks + add agent to hook input #9283

Open
opened 2026-02-16 18:12:05 -05:00 by yindo · 0 comments
Owner

Originally created by @ArmirKS on GitHub (Feb 13, 2026).

Originally assigned to: @thdxr on GitHub.

Description

prompt.ts has the same before/after plugin hook logic inline in 3 separate places, and none of them pass agent to the hooks. This means plugins can't tell which agent made a tool call — a blocker for any plugin that needs per-agent policy (audit logging, permission enforcement, etc).

Steps to reproduce

  1. Create a plugin that hooks tool.execute.before and logs the input
  2. Trigger tool calls from different agents (primary + subagents via task)
  3. Observe that the hook input has no agent field — the plugin can't distinguish who made the call

Fix

PR #13521 adds Tool.invoke() that centralizes hook wrapping and adds agent to the hook input.

The original batch bypass issue is moot since batch is experimental and being deprecated.

Originally created by @ArmirKS on GitHub (Feb 13, 2026). Originally assigned to: @thdxr on GitHub. ### Description `prompt.ts` has the same before/after plugin hook logic inline in 3 separate places, and none of them pass `agent` to the hooks. This means plugins can't tell which agent made a tool call — a blocker for any plugin that needs per-agent policy (audit logging, permission enforcement, etc). ### Steps to reproduce 1. Create a plugin that hooks `tool.execute.before` and logs the input 2. Trigger tool calls from different agents (primary + subagents via task) 3. Observe that the hook input has no `agent` field — the plugin can't distinguish who made the call ### Fix PR #13521 adds `Tool.invoke()` that centralizes hook wrapping and adds `agent` to the hook input. --- ~~The original batch bypass issue is moot since batch is experimental and being deprecated.~~
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9283