feat(provider): add gateway provider for OpenAI-compatible endpoints#1
Merged
Merged
Conversation
All existing providers (codex, claude, acpx, cursor, ...) shell out to a local CLI binary that has to be installed + OAuth'd on the host. That's a poor fit for containerized agent deployments where the only available LLM channel is an HTTP endpoint (LiteLLM gateway, vLLM, vanilla OpenAI). This adds a `gateway` provider that POSTs the already-assembled prompt to an OpenAI-compatible /chat/completions endpoint with structured outputs (response_format: json_schema). No subprocess; no extra CLI to install; same JSON contract as every other provider. Designed for the protoLabs LiteLLM gateway (internally http://gateway:4000/v1, externally https://api.proto-labs.ai/v1) but works against any OpenAI-compatible endpoint — vanilla OpenAI, vLLM, LM Studio, Ollama with the OpenAI shim, etc. Configuration: GATEWAY_API_KEY (preferred) or OPENAI_API_KEY — Bearer token OPENAI_BASE_URL default https://api.proto-labs.ai/v1 CLAWPATCH_GATEWAY_MODEL default protolabs/smart; --model on the CLI overrides CLAWPATCH_GATEWAY_TIMEOUT_MS default 300000 (5 min — reasoning models on big features can be slow) --reasoning-effort forwarded as `reasoning_effort` body field Because the buildReviewPrompt / buildMapPrompt / buildFixPrompt helpers already inline the relevant file contents as Files blocks, the gateway provider needs zero file IO. It's effectively the minimal provider implementation: prompt in, JSON out. The `check()` method validates env + returns a fingerprint string (model + base URL) without making a network call — `clawpatch doctor` won't spend tokens on a probe and won't time out when offline. +11 tests covering env precedence (GATEWAY_API_KEY > OPENAI_API_KEY), URL normalization (trailing slashes), model precedence (--model > CLAWPATCH_GATEWAY_MODEL > default), timeout parsing (garbage values fall back), check() fingerprint format, and the no-API-key auth-error path. 724 pass / 1 pre-existing skipped.
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.
Summary
All existing providers (codex, claude, acpx, cursor, opencode, grok, pi) shell out to a local CLI binary that has to be installed + OAuth'd on the host. That's a poor fit for containerized agent deployments where the only available LLM channel is an HTTP endpoint.
This adds a
gatewayprovider that POSTs the already-assembled prompt to an OpenAI-compatible/chat/completionsendpoint with structured outputs (response_format: json_schema). No subprocess; no extra CLI to install; same JSON contract as every other provider.Designed for the protoLabs LiteLLM gateway:
http://gateway:4000/v1https://api.proto-labs.ai/v1…but works against any OpenAI-compatible endpoint (vanilla OpenAI, vLLM, LM Studio, Ollama with the OpenAI shim).
Config
GATEWAY_API_KEY(preferred) orOPENAI_API_KEYOPENAI_BASE_URLhttps://api.proto-labs.ai/v1CLAWPATCH_GATEWAY_MODELprotolabs/smart--modelon the CLI winsCLAWPATCH_GATEWAY_TIMEOUT_MS300000(5 min)--reasoning-effortreasoning_effortbody fieldWhy this can be the minimal provider
buildReviewPrompt/buildMapPrompt/buildFixPromptalready inline the relevant file contents as Files blocks, so the gateway provider needs zero file IO — it's effectively the smallest possible provider: prompt in, JSON out.Smoke-test results
Verified end-to-end against
api.proto-labs.ai/v1:http://gateway:4000path which is the actual deploy target.)Test plan
pnpm test --run— 724 pass / 1 pre-existing skippedpnpm typecheckcleanFollow-ups
clawpatch ci --since <ref> --provider gatewayinto Quinn'spr_review(separate PR in protoWorkstacean)