Skip to content

fix(prompt-hook): skip Claude Code <agent-message> subagent hand-backs (#2184) - #2281

Merged
colbymchenry merged 2 commits into
mainfrom
carry/2190-prompt-hook-agent-message
Oct 2, 2026
Merged

colbymchenry merged 2 commits into
mainfrom
carry/2190-prompt-hook-agent-message

Conversation

@colbymchenry

Copy link
Copy Markdown
Owner

Carries #2190 by @danusha2345 onto current main. The commit keeps its author; the only addition is a changelog credit.

Closes #2184.

What was wrong

Claude Code hands a subagent's report back to the parent session as a UserPromptSubmit prompt wrapped in <agent-message from="…">…</agent-message>. The prompt hook already skips <task-notification> envelopes (#1832), but not this one. It ran a full explore on what are often multi-kilobyte reports, could go past Claude Code's 30-second hook timeout, and otherwise injected context matched from words in the report's prose.

Fix

isAgentMessage uses the same whole-prompt rule as isTaskNotification. Only a prompt that is entirely the envelope is skipped. A user question that mentions the tag, or text that continues after the closing tag, still runs the hook.

Verification

__tests__/frontload-hook.test.ts: 48 tests pass on current main. That includes the new cases for a hand-back that names indexed symbols, and for prompts that only mention the marker.

🤖 Generated with Claude Code

danusha2345 and others added 2 commits October 1, 2026 23:10
Claude Code delivers a subagent's report to the parent session as a
UserPromptSubmit prompt wrapped in <agent-message from="…">…</agent-message>.
The prompt hook treated it as user input and ran a full codegraph_explore
on the whole report, which is slow on a multi-KB prose query (past the
30 s hook timeout in the report) and injects context unrelated to the
user's question.

Add isAgentMessage next to isTaskNotification (#1832) with the same rule:
only a prompt that is entirely the envelope is skipped, so a user question
that mentions the tag still goes through the gate.

Fixes #2184

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 240022d)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

prompt-hook runs on Claude Code <agent-message> subagent hand-backs and hits the 30s hook timeout

1 participant