Skip to content

feat(hooks): guard subagent spawns (Task|Agent) toward graphify (#2145) - #2222

Open
ozdemirsarman wants to merge 1 commit into
Graphify-Labs:v8from
ozdemirsarman:fix/subagent-hook-guard
Open

feat(hooks): guard subagent spawns (Task|Agent) toward graphify (#2145)#2222
ozdemirsarman wants to merge 1 commit into
Graphify-Labs:v8from
ozdemirsarman:fix/subagent-hook-guard

Conversation

@ozdemirsarman

Copy link
Copy Markdown
Contributor

Closes #2145.

Problem

The PreToolUse hook-guard registers only Bash|Grep and Read|Glob matchers, but
most exploration happens inside spawned subagents. The main model spawns an Explore
agent 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 agent mode and register a Task|Agent PreToolUse matcher.
When a graph exists, the guard nudges the spawn (via additionalContext) to orient
through graphify before grepping/reading raw files — unless the subagent prompt is
already graphify-aware (mentions graphify, or carries pasted graph output like
Connections ( / [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|Agent hook). Updates the two existing install tests that assert the guard count
(2 → 3). Full hook/install/settings suites pass.

…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.
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.

hook-guard doesn't cover subagent spawns, where most exploration happens

3 participants