-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Problem
Power-steering's claude_power_steering.py hard-codes the Claude Agent SDK (claude_agent_sdk.query()). Users running gh copilot cannot use power-steering because they don't have the Claude SDK — they need the Copilot SDK (copilot.CopilotClient) instead.
Solution
Create a thin SDK abstraction layer (power_steering_sdk.py) that:
- Auto-detects the launcher via existing
LauncherDetector - Routes to the correct SDK backend (Claude or Copilot)
- Exposes a single interface:
async def query_llm(prompt, cwd) -> str - Maintains fail-open behavior (if neither SDK available, fall back to heuristics)
Interface
async def query_llm(prompt: str, cwd: str) -> str:
"""Send a prompt to the detected SDK and return the text response."""Detection
Uses existing LauncherDetector from src/amplihack/context/adaptive/detector.py which reads .claude/runtime/launcher_context.json.
SDK Call Sites (5 in claude_power_steering.py)
All follow the same pattern — create options, query, extract text. Each is currently a standalone call (no session reuse). Both SDKs support sessions, so session reuse can be added later as an optimization.
Files
- New:
.claude/tools/amplihack/hooks/power_steering_sdk.py— SDK abstraction (~80 lines) - Modified:
.claude/tools/amplihack/hooks/claude_power_steering.py— replace direct SDK calls withquery_llm()
Future Enhancement
Maintain a session across the 5 checks per stop event to avoid re-sending the transcript context 5 times. Both SDKs support sessions.
Related
- Existing SDK adapter pattern:
src/amplihack/agents/goal_seeking/sdk_adapters/ - Existing launcher detection:
src/amplihack/context/adaptive/detector.py - Copilot transcript support: refactor: split power_steering_checker.py into modular package with Copilot support (#2845) #2910