Repository navigation
Image generation: native provider migration and explicit capabilities - #49551
Conversation
🔒 Aisle Security AnalysisWe found 1 potential security issue(s) in this PR:
1. 🟡 Legacy nano-banana migration can persist resolved GEMINI_API_KEY into config file (secret exposure)
DescriptionThe In this codebase, config loading performs skills: {
entries: {
"nano-banana-pro": {
env: { GEMINI_API_KEY: "${GEMINI_API_KEY}" }
}
}
}is resolved at load time to the actual API key string. When Doctor runs:
This can unintentionally downgrade users from env-based secret management to cleartext secrets stored on disk. RecommendationAvoid writing resolved env-substituted secrets into new config paths. A safer migration strategy is:
import { DEFAULT_SECRET_PROVIDER_ALIAS } from "../config/types.secrets.js";
const legacyEnv = isRecord(rawLegacyEntry.env) ? rawLegacyEntry.env : undefined;
const hasLegacyEnvKey = typeof legacyEnv?.GEMINI_API_KEY === "string" && legacyEnv.GEMINI_API_KEY.trim().length > 0;
const legacyApiKey: SecretInput | undefined = hasLegacyEnvKey
? { source: "env", provider: DEFAULT_SECRET_PROVIDER_ALIAS, id: "GEMINI_API_KEY" }
: (typeof rawLegacyEntry.apiKey === "string"
? rawLegacyEntry.apiKey.trim()
: rawLegacyEntry.apiKey && isRecord(rawLegacyEntry.apiKey)
? structuredClone(rawLegacyEntry.apiKey)
: undefined);
Analyzed PR: #49551 at commit Last updated on: 2026-03-18T07:52:12Z |
544d155 to
7f9dacb
Compare
Greptile SummaryThis PR adds a native fal image-generation provider ( Key findings:
The doctor migration logic, fal provider implementation, and capability-type refactor all look well-structured and are backed by good test coverage. Confidence Score: 3/5
|
| resolution?: ImageGenerationResolution; | ||
| }) { | ||
| const provider = params.provider; | ||
| if (!provider) { | ||
| return; | ||
| } | ||
| const isEdit = params.inputImageCount > 0; | ||
| const modeCaps = isEdit ? provider.capabilities.edit : provider.capabilities.generate; | ||
| const geometry = provider.capabilities.geometry; | ||
| const maxCount = modeCaps.maxCount ?? MAX_COUNT; | ||
| if (params.count > maxCount) { | ||
| throw new ToolInputError( | ||
| `${provider.id} ${isEdit ? "edit" : "generate"} supports at most ${maxCount} output image${maxCount === 1 ? "" : "s"}.`, | ||
| ); | ||
| } | ||
|
|
||
| if (isEdit) { | ||
| if (!provider.capabilities.edit.enabled) { | ||
| throw new ToolInputError(`${provider.id} does not support reference-image edits.`); | ||
| } | ||
| const maxInputImages = provider.capabilities.edit.maxInputImages ?? MAX_INPUT_IMAGES; |
There was a problem hiding this comment.
edit.enabled check fires after maxCount, giving misleading error
When a provider declares edit.enabled: false (e.g. OpenAI) it also sets edit.maxCount: 0. The current ordering evaluates count > maxCount first — so a user passing any image to the OpenAI provider sees:
"openai edit supports at most 0 output images."
instead of the much clearer:
"openai does not support reference-image edits."
The edit.enabled guard should come before the maxCount check:
if (isEdit) {
if (!provider.capabilities.edit.enabled) {
throw new ToolInputError(`${provider.id} does not support reference-image edits.`);
}
const maxInputImages = provider.capabilities.edit.maxInputImages ?? MAX_INPUT_IMAGES;
if (params.inputImageCount > maxInputImages) {
throw new ToolInputError(
`${provider.id} edit supports at most ${maxInputImages} reference image${maxInputImages === 1 ? "" : "s"}.`,
);
}
}
const maxCount = modeCaps.maxCount ?? MAX_COUNT;
if (params.count > maxCount) {
throw new ToolInputError(
`${provider.id} ${isEdit ? "edit" : "generate"} supports at most ${maxCount} output image${maxCount === 1 ? "" : "s"}.`,
);
}Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/tools/image-generate-tool.ts
Line: 271-291
Comment:
**`edit.enabled` check fires after `maxCount`, giving misleading error**
When a provider declares `edit.enabled: false` (e.g. OpenAI) it also sets `edit.maxCount: 0`. The current ordering evaluates `count > maxCount` first — so a user passing any image to the OpenAI provider sees:
> "openai edit supports at most 0 output images."
instead of the much clearer:
> "openai does not support reference-image edits."
The `edit.enabled` guard should come before the `maxCount` check:
```typescript
if (isEdit) {
if (!provider.capabilities.edit.enabled) {
throw new ToolInputError(`${provider.id} does not support reference-image edits.`);
}
const maxInputImages = provider.capabilities.edit.maxInputImages ?? MAX_INPUT_IMAGES;
if (params.inputImageCount > maxInputImages) {
throw new ToolInputError(
`${provider.id} edit supports at most ${maxInputImages} reference image${maxInputImages === 1 ? "" : "s"}.`,
);
}
}
const maxCount = modeCaps.maxCount ?? MAX_COUNT;
if (params.count > maxCount) {
throw new ToolInputError(
`${provider.id} ${isEdit ? "edit" : "generate"} supports at most ${maxCount} output image${maxCount === 1 ? "" : "s"}.`,
);
}
```
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: 544d155ce1
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const selectedRef = | ||
| parseImageGenerationModelRef(params.modelOverride) ?? | ||
| parseImageGenerationModelRef(params.imageGenerationModelConfig.primary); |
There was a problem hiding this comment.
Include fallbacks when selecting provider for capability checks
This picks only modelOverride or the configured primary model, so capability validation can reject requests that would otherwise succeed via runtime failover. For example, with primary=openai/gpt-image-1, fallbacks=[google/gemini-3-pro-image-preview], and only Google auth available, a request with aspectRatio is rejected here before generateImage() can attempt the Google fallback. That breaks existing fallback behavior and blocks valid image-generation calls in degraded/auth-mismatch environments.
Useful? React with 👍 / 👎.
| (provider) => | ||
| provider.id === selectedRef.provider || (provider.aliases ?? []).includes(selectedRef.provider), |
There was a problem hiding this comment.
Normalize provider IDs before capability-provider matching
Provider matching here is case-sensitive, but runtime provider lookup normalizes IDs. If a user/config uses a mixed-case ref like OpenAI/gpt-image-1, this lookup misses, capability validation is skipped, and unsupported options can slip through (e.g., aspectRatio for OpenAI), which are then ignored by the provider path. That defeats the new “explicit capability” guardrails and produces inconsistent behavior for equivalent model refs.
Useful? React with 👍 / 👎.
…openclaw#49551) * Docs: retire nano-banana skill wrapper * Doctor: migrate nano-banana to native image generation * Image generation: align fal aspect ratio behavior * Image generation: make provider capabilities explicit
…openclaw#49551) * Docs: retire nano-banana skill wrapper * Doctor: migrate nano-banana to native image generation * Image generation: align fal aspect ratio behavior * Image generation: make provider capabilities explicit
…openclaw#49551) * Docs: retire nano-banana skill wrapper * Doctor: migrate nano-banana to native image generation * Image generation: align fal aspect ratio behavior * Image generation: make provider capabilities explicit
…openclaw#49551) * Docs: retire nano-banana skill wrapper * Doctor: migrate nano-banana to native image generation * Image generation: align fal aspect ratio behavior * Image generation: make provider capabilities explicit
…openclaw#49551) * Docs: retire nano-banana skill wrapper * Doctor: migrate nano-banana to native image generation * Image generation: align fal aspect ratio behavior * Image generation: make provider capabilities explicit
…openclaw#49551) * Docs: retire nano-banana skill wrapper * Doctor: migrate nano-banana to native image generation * Image generation: align fal aspect ratio behavior * Image generation: make provider capabilities explicit
…openclaw#49551) * Docs: retire nano-banana skill wrapper * Doctor: migrate nano-banana to native image generation * Image generation: align fal aspect ratio behavior * Image generation: make provider capabilities explicit
…openclaw#49551) * Docs: retire nano-banana skill wrapper * Doctor: migrate nano-banana to native image generation * Image generation: align fal aspect ratio behavior * Image generation: make provider capabilities explicit
…openclaw#49551) * Docs: retire nano-banana skill wrapper * Doctor: migrate nano-banana to native image generation * Image generation: align fal aspect ratio behavior * Image generation: make provider capabilities explicit
Summary
nano-banana-proskill and migrate users to native image generation via doctorWhat changed
extensions/fal/*andsrc/image-generation/providers/fal.tsskills.entries.nano-banana-protoagents.defaults.imageGenerationModelimage_generatepathsrc/image-generation/types.tsimage_generatefor list output and early validationNotes
midjourneycode or strings remain in this branch diff