-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Description
Power-steering stop hook incorrectly activates on Q&A/PM/Operations sessions and blocks with development/investigation checks that don't apply. During a /pm-architect session (pure project management prioritization with no code changes), the hook repeatedly blocked with checks like workflow_invocation, next_steps, documentation_updates.
Root Cause Analysis
Two issues in session_detection.py:
1. Investigation keyword matching picks up system-injected content
The detect_session_type() method scans the first 5 user messages for investigation keywords (line 391). However, Claude Code injects system-reminder content into user message slots, which contain words like "understand" (from skill descriptions, CLAUDE.md context, etc.). The keyword "understand" matched in the PM session's transcript even though the actual user request was "please help prioritize next steps".
Evidence from log:
DEBUG: Investigation keyword 'understand' found in user message
INFO: Session classified as INVESTIGATION via keywords (no code modifications)
2. _is_qa_session() is too narrow for tool-using Q&A
The _is_qa_session() method (line 479) returns False if tool_uses >= 2. But legitimate Q&A/PM sessions use tools extensively (Bash for gh commands, Read/Write for docs). A PM prioritization session had ~15 tool calls but was purely operational — no code changes.
3. No "OPERATIONS" session type
detect_session_type() supports SIMPLE, DEVELOPMENT, INFORMATIONAL, MAINTENANCE, and INVESTIGATION but lacks an OPERATIONS type for PM work, git operations, and administrative tasks that use tools but don't change code.
Impact
- Sessions blocked 4-5 times with irrelevant checks before auto-approval
- Wasted user time and tokens on repeated power-steering analysis cycles
- Checks like
workflow_invocation(requires dev workflow) andnext_steps(a project backlog IS next steps) are nonsensical for PM queries
Expected Behavior
Q&A and Operations sessions should either:
- Skip power-steering entirely, OR
- Apply a minimal set of checks appropriate to the session type
Reproduction
- Run
/pm-architect please help prioritize next steps - Provide the prioritization analysis with gh commands
- Try to stop the session
- Observe power-steering blocking with INVESTIGATION checks
Proposed Fix
- Filter system-reminder content from keyword matching — Only match keywords in actual user-authored content, not system-injected messages
- Add OPERATIONS session type — For PM, admin, and git tasks that use tools but don't modify code files
- Expand
_is_qa_session()or add operations detection — Recognize sessions that use Bash forgh/gitcommands and Write for.mddocs as non-development
Files
.claude/tools/amplihack/hooks/power_steering_checker/session_detection.py— Main fix location.claude/tools/amplihack/hooks/power_steering_checker/main_checker.py— QA session early-exit
Related
- Recent refactor: refactor: split power_steering_checker.py into modular package with Copilot support (#2845) #2910 (split power_steering_checker into package)