fix(rust): accept subagent lifecycle hooks - #2783
Open
hackberry-lab wants to merge 2 commits into
Open
hackberry-lab wants to merge 2 commits into
hackberry-lab wants to merge 2 commits into
Conversation
Treat subagentStart and subagentStop as recognized pass-through hooks so valid CLI lifecycle callbacks do not emit unknown-hook warnings. Add focused classification and dispatch coverage.\n\nRefs github#2781
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused change correctly avoids the unknown-hook path while preserving existing behavior for unrelated hooks.
Review effort: Balanced
Findings: None
What changed in this PR
Recognizes valid Rust subagent lifecycle callbacks without changing the public hooks API.
Changes:
- Passes through
subagentStartandsubagentStopwith empty output. - Tests both lifecycle names and an unrelated name.
| File | Description |
|---|---|
rust/src/hooks.rs |
Adds lifecycle-hook classification, dispatch handling, and tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This branch has not been deployed
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.
Summary
subagentStartandsubagentStopas valid callback-only lifecycle hooks in the Rust dispatcherThe public
SessionHooksAPI remains unchanged. Sub-agent lifecycle activity continues to be available through the session event stream; this change only prevents valid CLI callbacks from being misclassified as unknown.Fixes #2781
Validation
cargo test --features test-support hooks::tests::dispatch_subagent_lifecycle_hooks_returns_empty -- --exactcargo +nightly-2026-04-14 fmt --all -- --config-path .rustfmt.nightly.toml --checkcargo clippy --all-targets --no-default-features --features test-support,local-runtime,derive -- --no-deps -D warnings -D clippy::unwrap_used -D clippy::disallowed_macros -D clippy::await_holding_invalid_typecargo test --no-default-features --features test-support,derive -- --test-threads=4 --nocaptureRUSTDOCFLAGS="-D warnings" cargo doc --no-deps --no-default-features --features local-runtime,derive