feat(hooks): guard subagent spawns (Task|Agent) toward graphify (#2145) - #2222
Open
ozdemirsarman wants to merge 1 commit into
Open
feat(hooks): guard subagent spawns (Task|Agent) toward graphify (#2145)#2222ozdemirsarman wants to merge 1 commit into
ozdemirsarman wants to merge 1 commit into
Conversation
…hify-Labs#2145) The PreToolUse hook-guard registered only Bash|Grep and Read|Glob matchers, but most exploration happens inside spawned subagents (Task/Agent) — the parent spawns an Explore agent that never sees the guard. Add a 'hook-guard agent' mode + a Task|Agent matcher that nudges a spawn to carry graphify orientation when a graph exists, unless the prompt is already graphify-aware. Advisory only: a spawn is never blocked; fails open on an absent graph or empty brief. Uninstall filters updated to strip the new matcher. Adds tests.
aftabpthn
approved these changes
Jul 26, 2026
aftabahamad260-code
approved these changes
Jul 26, 2026
aftabahamad260-code
approved these changes
Jul 26, 2026
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.
Closes #2145.
Problem
The PreToolUse hook-guard registers only
Bash|GrepandRead|Globmatchers, butmost exploration happens inside spawned subagents. The main model spawns an
Exploreagent with "find all callers of X", and that agent never sees the guard — so the
graph-orientation nudge is bypassed exactly where it matters most.
Fix
Add a
graphify hook-guard agentmode and register aTask|AgentPreToolUse matcher.When a graph exists, the guard nudges the spawn (via
additionalContext) to orientthrough graphify before grepping/reading raw files — unless the subagent prompt is
already graphify-aware (mentions
graphify, or carries pasted graph output likeConnections (/[EXTRACTED]), in which case it stays quiet.Advisory only: it never blocks a spawn, and fails open on an absent graph, an empty
brief, or malformed stdin — consistent with the existing search/read guards. The
install/uninstall filters are updated so the new matcher is registered and cleanly
removed alongside the others.
Tests
Adds
tests/test_agent_hook.py(nudges on exploration spawns; silent without a graph,on empty briefs, and when already graphify-aware; never blocks; valid PreToolUse JSON;
fails open on malformed stdin; uninstall filter strips ours but preserves a foreign
Task|Agenthook). Updates the two existing install tests that assert the guard count(2 → 3). Full hook/install/settings suites pass.