Skip to content

Filter hook handlers by emitted tool profile - #97

Draft
jonathanhefner wants to merge 1 commit into
agentplugins:agent/portable-hooksfrom
jonathanhefner:agent/hook-tool-profile-matching
Draft

jonathanhefner wants to merge 1 commit into
agentplugins:agent/portable-hooksfrom
jonathanhefner:agent/hook-tool-profile-matching

Conversation

@jonathanhefner

Copy link
Copy Markdown
Member

Note

This is based on the changes from #89.

Summary

Add an optional toolProfiles field to handler configurations for PreToolUse and PostToolUse. A nonempty list of portable tool profile names limits the handler to events whose emitted tool_profile.name exactly matches a listed name.

Clients evaluate the filter before launching the handler process. An event without a matching profile does not launch that handler. Omitting toolProfiles preserves invocation for every occurrence of the configured event.

Motivation

The hooks proposal launches every valid handler configured for an event. A handler interested only in file.modify still starts for an event with a shell profile, reads the input, and exits without a result. With several plugins or handlers, a single tool call may launch multiple such processes.

This addresses the request for declarative matching in the hooks review.

Rationale

Filtering before process launch avoids that work. Portable profile names give one filter configuration a consistent meaning across clients, whose native tool names differ. Clients can apply the filter to the event input they already produce, preserving the existing profile-production requirements. Finer filtering remains in handler code.

Add optional `toolProfiles` lists to individual `PreToolUse` and
`PostToolUse` handler configurations so clients can avoid launching
processes that would immediately discard an event based on its portable
profile name.

Match the current emitted `tool_profile.name` by exact equality for each
event occurrence. A missing profile does not match; an omitted filter
preserves invocation for every occurrence. Retain existing
profile-production requirements and per-handler configuration failure
isolation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant