Skip to content

bug: power-steering incorrectly activates on Q&A/PM sessions, blocks with inapplicable checks #2914

@rysweet

Description

@rysweet

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) and next_steps (a project backlog IS next steps) are nonsensical for PM queries

Expected Behavior

Q&A and Operations sessions should either:

  1. Skip power-steering entirely, OR
  2. Apply a minimal set of checks appropriate to the session type

Reproduction

  1. Run /pm-architect please help prioritize next steps
  2. Provide the prioritization analysis with gh commands
  3. Try to stop the session
  4. Observe power-steering blocking with INVESTIGATION checks

Proposed Fix

  1. Filter system-reminder content from keyword matching — Only match keywords in actual user-authored content, not system-injected messages
  2. Add OPERATIONS session type — For PM, admin, and git tasks that use tools but don't modify code files
  3. Expand _is_qa_session() or add operations detection — Recognize sessions that use Bash for gh/git commands and Write for .md docs 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions