Skip to content

feat: power-steering SDK abstraction — auto-select Claude or Copilot SDK #2917

@rysweet

Description

@rysweet

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:

  1. Auto-detects the launcher via existing LauncherDetector
  2. Routes to the correct SDK backend (Claude or Copilot)
  3. Exposes a single interface: async def query_llm(prompt, cwd) -> str
  4. 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 with query_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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions