Repository navigation
Conversation
Registers litellm as an image-generation provider so model refs like litellm/gpt-image-2 route through the LiteLLM proxy, and agents.defaults.imageGenerationModel.fallbacks entries of the form litellm/... resolve without "No image-generation provider registered for litellm" errors. Implementation uses the OpenAI-compatible /images/generations and /images/edits endpoints that LiteLLM proxies for. BaseUrl resolves from models.providers.litellm.baseUrl (default http://localhost:4000). Private network is auto-allowed when baseUrl is a loopback/RFC1918 address, which covers the common self-hosted LiteLLM proxy case without needing OPENCLAW_PROVIDER_ALLOW_PRIVATE_NETWORK. Public baseUrls keep normal SSRF defaults. Default model is gpt-image-2 (matching upstream 4.21+ OpenAI default). Advertises the same 2K/4K sizes OpenAI now exposes, plus legacy 256/512/1024 for dall-e-3. Supports both generate and edit. Local patch. LiteLLM has no upstream image-generation support yet; revisit if upstream adds one.
Greptile SummaryThis PR registers The implementation is well-structured and consistent with other image-gen providers in the codebase. One minor dead-code branch exists in Confidence Score: 5/5Safe to merge — the only finding is a single dead-code branch that does not affect behaviour or security. All findings are P2 (style/dead-code). Core logic for auth, URL resolution, private-network detection, generate/edit routing, and response mapping is correct and well-tested. No files require special attention. Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/litellm/image-generation-provider.ts
Line: 55
Comment:
**Dead code — bare `"::1"` never matches `URL.hostname`**
Per the WHATWG URL spec (and Node.js `URL`), `new URL("http://[::1]:4000").hostname` returns `"[::1]"` (brackets included), never the bare string `"::1"`. The check on this line is therefore unreachable. The adjacent `lower === "[::1]"` check on the next line already handles IPv6 loopback correctly, so the behaviour is still correct — but the bare-string branch is dead code and could mislead future maintainers.
```suggestion
lower === "[::1]" ||
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "extensions/litellm: fix test dispatcher ..." | Re-trigger Greptile |
| return ( | ||
| lower === "127.0.0.1" || | ||
| lower === "localhost" || | ||
| lower === "::1" || |
There was a problem hiding this comment.
Dead code — bare
"::1" never matches URL.hostname
Per the WHATWG URL spec (and Node.js URL), new URL("http://[::1]:4000").hostname returns "[::1]" (brackets included), never the bare string "::1". The check on this line is therefore unreachable. The adjacent lower === "[::1]" check on the next line already handles IPv6 loopback correctly, so the behaviour is still correct — but the bare-string branch is dead code and could mislead future maintainers.
| lower === "::1" || | |
| lower === "[::1]" || |
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/litellm/image-generation-provider.ts
Line: 55
Comment:
**Dead code — bare `"::1"` never matches `URL.hostname`**
Per the WHATWG URL spec (and Node.js `URL`), `new URL("http://[::1]:4000").hostname` returns `"[::1]"` (brackets included), never the bare string `"::1"`. The check on this line is therefore unreachable. The adjacent `lower === "[::1]"` check on the next line already handles IPv6 loopback correctly, so the behaviour is still correct — but the bare-string branch is dead code and could mislead future maintainers.
```suggestion
lower === "[::1]" ||
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d6c29aac5e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| lower.startsWith("10.") || | ||
| lower.startsWith("192.168.") || | ||
| /^172\.(1[6-9]|2[0-9]|3[0-1])\./.test(lower) || |
There was a problem hiding this comment.
Match RFC1918 hosts strictly before enabling private network
The private-network auto-allow check uses prefix matching (startsWith("10."), startsWith("192.168."), and the 172.* regex) on parsed.hostname, which also matches normal DNS names like 10.example.com or 172.16.example.com. In those cases allowPrivateNetwork is turned on even though the host is not a literal RFC1918 IP, weakening SSRF protections for a broader set of configured endpoints than intended.
Useful? React with 👍 / 👎.
|
Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch. |
|
Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f16b6a1fa4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| function hasDependencySentinel(searchRoots: readonly string[], dep: { name: string }): boolean { | ||
| return searchRoots.some((rootDir) => | ||
| fs.existsSync(path.join(rootDir, dependencySentinelPath(dep.name))), | ||
| ); |
There was a problem hiding this comment.
Validate runtime dep versions before treating them as installed
ensureBundledPluginRuntimeDeps computes missingSpecs from hasDependencySentinel, but this helper now only checks whether node_modules/<name>/package.json exists and never verifies dep.version. If a plugin requires one version/range and another incompatible version is already present in a searched root, install is skipped and the plugin loads against the wrong dependency API, which can fail at runtime. The sentinel check needs version/range validation again before suppressing installation.
Useful? React with 👍 / 👎.
| const { ProxyAgent } = loadUndiciRuntimeDeps(); | ||
| return new ProxyAgent({ | ||
| requestTls: cert !== undefined || key !== undefined ? { cert, key } : undefined, | ||
| uri: proxyUri, | ||
| }); |
There was a problem hiding this comment.
Reuse or dispose undici agents in gaxios compat fetch
When proxy or TLS options are present, buildDispatcher allocates a fresh ProxyAgent (and similarly an Agent in the TLS branch) per request with no caching or teardown path. In long-running sessions that make many gaxios calls behind a proxy/mTLS, this can accumulate connection pools and handles instead of reusing transport state, causing memory/socket growth and degraded performance.
Useful? React with 👍 / 👎.
|
Related work from PRtags group Title: Open PR duplicate: LiteLLM image generation provider
|
Summary
Registers
litellmas an image-generation provider so model refs likelitellm/gpt-image-2route through the LiteLLM proxy, andagents.defaults.imageGenerationModel.fallbacksentries of the formlitellm/...resolve instead of failing withNo image-generation provider registered for litellm.LiteLLM proxies OpenAI-compatible endpoints, so this uses the same
/images/generationsand/images/editsshape the bundled OpenAI provider does. The existing LiteLLM API key is reused (no new auth surface). BaseUrl resolves frommodels.providers.litellm.baseUrland falls back to theLITELLM_BASE_URLdefault already used by the text completion provider.Private network handling
Since LiteLLM is typically deployed as a self-hosted proxy, the provider auto-allows private network when the configured
baseUrlresolves to a loopback or RFC1918 address (127.0.0.1, localhost, [::1], 10.x, 192.168.x, 172.16-31.x, host.docker.internal). This matches real-world LiteLLM deployments without requiring a globalOPENCLAW_PROVIDER_ALLOW_PRIVATE_NETWORKoverride. Public baseUrls keep normal SSRF defaults.Defaults
defaultModel:gpt-image-2(matches the upstream OpenAI default from providers: default Moonshot to Kimi 2.6 #69477-era changes)256x256/512x512/1024x1024for dall-e-3 through the new 2K/4K sizes (2048x2048,3840x2160, etc.) for gpt-image-2generateandeditcapabilities enabled (editaccepts up to 5 input images)Actual image models available depend on what the operator's LiteLLM proxy is configured to route — the provider just forwards requests; it does not enumerate remote models.
Contract
extensions/litellm/openclaw.plugin.jsondeclares"contracts": { "imageGenerationProviders": ["litellm"] }so the capability is discovered through the existing manifest path used by every other image-gen provider plugin.Test plan
extensions/litellm/image-generation-provider.test.tscover:allowPrivateNetwork: trueallowPrivateNetwork: falsecountandsizeoverrides forwarded on generateinputImagespresentpnpm checkgreen (typecheck + lint + policy guards)pnpm buildproduces a clean distgpt-image-2configured (not run in CI — requires user-provided LiteLLM setup)