fix(hooks): match tool hooks against the model-facing Agent name#3236
Open
abhay-codes07 wants to merge 1 commit into
Open
fix(hooks): match tool hooks against the model-facing Agent name#3236abhay-codes07 wants to merge 1 commit into
abhay-codes07 wants to merge 1 commit into
Conversation
PreToolUse/PostToolUse hooks for built-in tools were matched against the internal tool name, but the subagent tool executes internally as Task while users, docs, and the model all see it as Agent. A hook registered with matcher "Agent" therefore never fired for subagent dispatches. Pass both names to the tool hook runners: matchers now fire on either the model-facing name or the internal name (so existing "Task" matchers keep working), and hook payloads report the model-facing name as tool_name. Fixes letta-ai#3150
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Taskwhile users, the docs, and the model all see it asAgent. A hook registered with matcher"Agent"therefore never fired for subagent dispatches (server-executed tools already matched on the model-facing name, so the two paths disagreed)."Task"matchers keep working — and hook payloads report the model-facing name astool_name. This also covers the Gemini toolset mappings (e.g. matcherglobnow matches internalglob_gemini).Agentmatcher in the hooks reference.Fixes #3150.
Test plan
bun test src/hooks/— new loader tests for alias matching (fail without the fix) and integration tests asserting anAgentmatcher fires for a["Agent", "Task"]call withtool_name: "Agent"in the payload, plus legacyTaskmatcher compatibilitybun run checkmainbaseline on the same machine.letta/settings.jsonPreToolUse hook with matcherAgentexecutes 0 times with the old call shape and once with the new oneAI disclosure
Following the policy proposed in #3139: this PR was developed with AI assistance (Claude Code) — the investigation, patch, and tests were AI-assisted. I directed the work, reviewed the change, and ran the validation above locally.
cc @jnjpng — you seem closest to
src/hooks/; happy to adjust if you'd prefer the payload to keep reporting the internal name.