← Back to Pull requests

feat(hcpctl): add claude-code LLM provider for snapshot analyze #7574

Closed
unknown closed this pull request without merging on Oct 19, 2026 08:59 UTC
View on GitHub
unknown unknown commented on Oct 16, 2026 08:19 UTC
Author

Summary

https://redhat.atlassian.net/browse/ARO-30249

Adds a third LLM provider, claude-code, to hcpctl snapshot analyze, alongside the existing copilot and claude providers. The new provider runs the Claude Code CLI as a subprocess (via github.com/roasbeef/claude-agent-sdk-go v1.1.0), giving the Claude path the same autonomous filesystem exploration (Read/Grep/Glob/Bash) that the Copilot path already has. This closes the capability gap where the in-process claude provider only exposed the kusto_query tool and could not grep/read the cloned repo worktrees.

The existing copilot and claude providers are unchanged; this is purely additive.

What changed

  • New pkg/agent/claude_code_provider.go implementing the provider-neutral LLMProvider/LLMSession interfaces, backed by the roasbeef Claude Code Go SDK.

  • kusto_query exposed to the CLI agent via an in-process MCP server, wrapping the existing ToolDefinition.Handler, so the custom tool behaves identically across providers.

  • Guardrails: --strict-mcp-config (no filesystem MCP discovery), bypass-permissions for unattended/headless runs, working directory pinned to the analyze workspace, and best-effort CLAUDE.md/settings isolation.

  • Default model claude-sonnet-4-5-20250929 when none is supplied (the SDK rejects an empty model); explicit Connect with terminal-result handling so a silent/non-terminal query end is treated as an error.

  • Best-effort usage/cost mapping into UsageReport/UsageBreakdown from the SDK's ResultMessage (TotalCostUSD/Usage/ModelUsage); a code comment notes this is coarser than the in-process Anthropic provider.

  • Wired into cmd/snapshot/analyze_cmd.go: new providerClaudeCode = "claude-code" constant, cases in both the validation and runtime-construction switches, with kustoTool registered for this path.

  • Unit tests in pkg/agent/claude_code_provider_test.go, mirroring the existing claude_provider_test.go style (no network, no real claude binary required).
  • Testing

  • make -C tooling/hcpctl build — pass

  • go test ./... in tooling/hcpctl (19 packages) — pass

  • go vet ./... — pass

  • lint / gci / gofmt — pass

  • clean working tree
  • Notes / follow-ups

  • github.com/roasbeef/claude-agent-sdk-go is a community (unofficial) SDK, pinned to v1.1.0.

  • Full CLAUDE.md/AGENTS.md isolation is not currently expressible through the SDK; it is mitigated via an isolated working directory plus strict MCP config, and the residual limitation is documented in code.

  • Fine-grained token accounting (cache-TTL / service-tier breakdown) available to the in-process claude provider is not fully reproduced here; cost and aggregate token totals are reported.
  • ---
    AI-generated. Review for accuracy.

    @geoberle requested from Slack

    Diff: 356 lines (+267 / -89) across 4 files Reviewer: geoberle Review duration: 4360m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 356 lines diff across 4 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.352
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #7574"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.5% (MEDIUM) · Higher = larger blast radius
    47.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.8% · Safe to merge
    18.8%
    Repository