Repository navigation
fix(prompt-hook): skip Claude Code <agent-message> subagent hand-backs (#2184) - #2281
Merged
Merged
Conversation
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>
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.
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
UserPromptSubmitprompt 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
isAgentMessageuses the same whole-prompt rule asisTaskNotification. 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 currentmain. 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