feat(ai-review): add agent LLM provider backed by local Claude Code#93
Merged
Conversation
Add an 'agent' value to LLM_PROVIDER that routes reviews through a local Claude Code agent exposing POST /trigger and running `claude -p`. This lets a deployment reuse an existing Claude subscription on the host instead of an Anthropic API key, which matters when ClearPR runs in Docker and cannot invoke the host `claude` binary or read its credentials directly.
AgentLlmAdapter POSTs the prompt with a bearer token, maps the agent's {result.result, usage, modelUsage} payload onto LlmResponse, applies a 600s timeout matching the agent ceiling, and surfaces timeouts and malformed payloads as the existing review errors. Wire it into the enum, registry, and default-model map, document it in the README and provider guide, and add host.docker.internal:host-gateway to the compose app service so the container can reach a host-side agent.
981f3b9 to
0d5e017
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a sixth
LLM_PROVIDERvalue,agent, that routes reviews through a local Claude Code agent exposingPOST /trigger(which runsclaude -pnon-interactively) instead of calling an LLM API directly.Why
When ClearPR runs in Docker, it cannot invoke the host's
claudebinary or read its credentials. Pointing the new provider at a small host-side agent lets a deployment reuse an existing Claude subscription on the host, so no Anthropic API key is needed.How
AgentLlmAdapterPOSTs the prompt withAuthorization: Bearer <LLM_API_KEY>, maps the agent's{ result.result, usage, modelUsage }payload ontoLlmResponse, applies a 600s timeout matching the agent's own ceiling, and surfaces aborts asLlmTimeoutErrorand bad payloads asMalformedLlmResponseError.LlmProviderenum,llm-provider.registry.ts, and the default-model map (claude-code).docker-compose.ymlgainshost.docker.internal:host-gatewayso the container can reach a host-side agent.Config
Tests
6 new unit tests for the adapter (success mapping, model fallback, error result, non-2xx, abort to timeout). Full suite 170/170,
tsc/eslint/nest buildclean.