Repository navigation
fix(prompt-hook): skip Claude Code <agent-message> subagent hand-backs (#2184) - #2190
Closed
danusha2345 wants to merge 1 commit into
Closed
danusha2345 wants to merge 1 commit into
danusha2345 wants to merge 1 commit into
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 (colbymchenry#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 colbymchenry#2184 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Thank you! This landed in #2281: your commit carried onto current |
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.
Fixes #2184
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 treated it as user input and ran a fullcodegraph_exploreon the whole report. That is slow on a multi-KB prose query — past Claude Code's 30 s hook timeout in the report — and when it does finish, the injected context is matched from words in the report, not from anything the user asked.Change
isAgentMessage(prompt)next toisTaskNotification(prompt-hook fires on Claude Code's system-injected<task-notification>messages: 3.5s median, 7.4s max on the blocking path #1832/fix(prompt-hook): skip Claude Code task notifications (#1832) #1884), same rule: only a prompt that is entirely the envelope is skipped, so a user question that quotes the tag still goes through the gate.codegraph prompt-hookreturns before any project lookup when either matches.Tests
isAgentMessage(full envelope, surrounding whitespace, no attributes; a user question quoting it, trailing text,<agent-messages>and an unclosed envelope are not skipped).<agent-message>.main(the hook injects explore output for the envelope) and pass with the fix.Measured
On a 375-file index, an 8 KB report took the hook 60 s on
main; wrapped in<agent-message>it now exits in 0.17 s.Not in this PR
Hook time grows faster than prompt length (500 chars → 2.3 s, 2 KB → 13 s, 4 KB → 40 s on that index): explore runs a separate search for every query term, with no cap on how many, re-reads
SELECT DISTINCT name FROM nodesper term in the fuzzy/substring passes, and re-splits the whole query for every candidate path inscorePathRelevance. So a ~4 KB prose prompt typed by a user can still pass the 30 s timeout. Happy to follow up separately.🤖 Generated with Claude Code