Skip to content

Image generation: native provider migration and explicit capabilities - #49551

Merged
vincentkoc merged 4 commits into
mainfrom
vincentkoc-code/midjourney-skill
Mar 18, 2026
Merged

vincentkoc merged 4 commits into
mainfrom
vincentkoc-code/midjourney-skill

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

Summary

  • add native fal image-generation provider and onboarding
  • retire the bundled nano-banana-pro skill and migrate users to native image generation via doctor
  • make image-generation provider capabilities explicit so provider differences are validated early and surfaced honestly
  • keep Midjourney out of the codebase; no Midjourney provider or skill is included here

What changed

  • add extensions/fal/* and src/image-generation/providers/fal.ts
  • add doctor migration from skills.entries.nano-banana-pro to agents.defaults.imageGenerationModel
  • move Google/Nano Banana-style flows onto the native image_generate path
  • add explicit provider capability fields in src/image-generation/types.ts
  • use provider capabilities in image_generate for list output and early validation

Notes

  • no midjourney code or strings remain in this branch diff
  • local static diff checks passed
  • local Vitest completion remained unreliable in this checkout, so this PR is being merged on code review + scoped tests-in-code rather than a trusted local green run

@aisle-research-bot

aisle-research-bot Bot commented Mar 18, 2026 •

Copy link
Copy Markdown

🔒 Aisle Security Analysis

We found 1 potential security issue(s) in this PR:

# Severity Title
1 🟡 Medium Legacy nano-banana migration can persist resolved GEMINI_API_KEY into config file (secret exposure)

1. 🟡 Legacy nano-banana migration can persist resolved GEMINI_API_KEY into config file (secret exposure)

Property Value
Severity Medium
CWE CWE-312
Location src/commands/doctor-legacy-config.ts:536-562

Description

The normalizeLegacyNanoBananaSkill() migration copies skills.entries["nano-banana-pro"].env.GEMINI_API_KEY (a string) into models.providers.google.apiKey.

In this codebase, config loading performs ${VAR} environment substitution across all string values (see resolveConfigEnvVars). That means a config value like:

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:

  • Input: rawLegacyEntry.env.GEMINI_API_KEY is already the resolved secret string
  • Transformation: migration sets models.providers.google.apiKey = legacyApiKey
  • Output sink: openclaw doctor --fix writes the migrated config back to disk
  • Problem: the write-back env-reference preservation (restoreEnvVarRefs) can only restore ${VAR} placeholders at the same path where they originally existed. Since the migration moves the value to a different path, the placeholder cannot be restored, so the resolved secret gets written into openclaw.json.

This can unintentionally downgrade users from env-based secret management to cleartext secrets stored on disk.

Recommendation

Avoid writing resolved env-substituted secrets into new config paths.

A safer migration strategy is:

  1. If the legacy value came from env.GEMINI_API_KEY, migrate it as a SecretRef instead of a string (so it remains an env-backed reference), e.g.:
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);
  1. Optionally, only fall back to the env.GEMINI_API_KEY string when it is clearly not an env-template substitution (requires access to pre-substitution parsed config) or when the user explicitly opted in.

  2. Add a regression test where legacy config uses "${GEMINI_API_KEY}" and assert the written config ends up with a SecretRef (or preserves a placeholder), not the resolved secret string.


Analyzed PR: #49551 at commit 7f9dacb

Last updated on: 2026-03-18T07:52:12Z

@vincentkoc vincentkoc self-assigned this Mar 18, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime commands Command implementations agents Agent runtime and tooling extensions: fal size: XL maintainer Maintainer-authored PR labels Mar 18, 2026
@vincentkoc
vincentkoc force-pushed the vincentkoc-code/midjourney-skill branch from 544d155 to 7f9dacb Compare March 18, 2026 07:03
@vincentkoc
vincentkoc merged commit 21c2ba4 into main Mar 18, 2026
11 checks passed
@vincentkoc
vincentkoc deleted the vincentkoc-code/midjourney-skill branch March 18, 2026 07:04
@greptile-apps

greptile-apps Bot commented Mar 18, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a native fal image-generation provider (extensions/fal + src/image-generation/providers/fal.ts), retires the bundled nano-banana-pro skill with an automated doctor migration, and upgrades all existing providers to a richer, structured ImageGenerationProviderCapabilities type that enables early tool-level validation of count limits, edit support, aspect ratios, sizes, and resolutions.

Key findings:

  • Check ordering bug in validateImageGenerationCapabilities — The count > maxCount guard runs before the edit.enabled guard. For providers like OpenAI that declare edit.enabled: false and edit.maxCount: 0, a user supplying a reference image receives the cryptic error "openai edit supports at most 0 output images" instead of the intended "openai does not support reference-image edits". Moving the edit.enabled check to the top of the isEdit branch fixes this.

  • Duplicate CHANGELOG breaking-change entry — The Skills/image generation: remove the bundled nano-banana-pro skill wrapper bullet appears twice in the ### Breaking section of CHANGELOG.md.

  • Duplicate docs bullet in configuration-reference.md — Two "Typical values" entries for imageGenerationModel are rendered back-to-back; the second (shorter) one is redundant.

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

  • Mostly safe to merge, but the check-ordering bug in capability validation surfaces a misleading user-facing error for the OpenAI provider and should be fixed first.
  • The feature is well-tested and the migration logic is sound. The main issue is a wrong-ordering guard in validateImageGenerationCapabilities that produces a confusing error message for providers with edit disabled, plus two cosmetic duplication issues in docs and the changelog.
  • src/agents/tools/image-generate-tool.ts (validateImageGenerationCapabilities check order), CHANGELOG.md (duplicate entry), docs/gateway/configuration-reference.md (duplicate bullet)

Comments Outside Diff (2)

  1. CHANGELOG.md, line 25-26 (link)

    P2 Duplicate breaking-change entry

    The Skills/image generation: remove the bundled nano-banana-pro skill wrapper entry appears twice in the ### Breaking section — once at the top of the block (line 25–26) and again a few lines later (line 30). One of them should be removed.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: CHANGELOG.md
    Line: 25-26
    
    Comment:
    **Duplicate breaking-change entry**
    
    The `Skills/image generation: remove the bundled nano-banana-pro skill wrapper` entry appears twice in the `### Breaking` section — once at the top of the block (line 25–26) and again a few lines later (line 30). One of them should be removed.
    
    
    
    How can I resolve this? If you propose a fix, please make it concise.
  2. docs/gateway/configuration-reference.md, line 42-44 (link)

    P2 Duplicate "Typical values" bullet point

    Two nearly identical "Typical values" bullets are rendered back-to-back in the same list item context — one with narrative context and one as a plain list. The second one (line 44) is redundant and should be dropped:

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: docs/gateway/configuration-reference.md
    Line: 42-44
    
    Comment:
    **Duplicate "Typical values" bullet point**
    
    Two nearly identical "Typical values" bullets are rendered back-to-back in the same list item context — one with narrative context and one as a plain list. The second one (line 44) is redundant and should be dropped:
    
    
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All 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.

---

This is a comment left during a code review.
Path: CHANGELOG.md
Line: 25-26

Comment:
**Duplicate breaking-change entry**

The `Skills/image generation: remove the bundled nano-banana-pro skill wrapper` entry appears twice in the `### Breaking` section — once at the top of the block (line 25–26) and again a few lines later (line 30). One of them should be removed.

```suggestion
 ### Breaking
 
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: docs/gateway/configuration-reference.md
Line: 42-44

Comment:
**Duplicate "Typical values" bullet point**

Two nearly identical "Typical values" bullets are rendered back-to-back in the same list item context — one with narrative context and one as a plain list. The second one (line 44) is redundant and should be dropped:

```suggestion
  - Typical values: `google/gemini-3-pro-image-preview` for the native Nano Banana-style flow, `fal/fal-ai/flux/dev` for fal, or `openai/gpt-image-1` for OpenAI Images.
  - If omitted, `image_generate` can still infer a best-effort provider default from compatible auth-backed image-generation providers.
```

How can I resolve this? If you propose a fix, please make it concise.

Last reviewed commit: "Image generation: ma..."

Comment on lines +271 to +291
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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +253 to +255
const selectedRef =
parseImageGenerationModelRef(params.modelOverride) ??
parseImageGenerationModelRef(params.imageGenerationModelConfig.primary);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +260 to +261
(provider) =>
provider.id === selectedRef.provider || (provider.aliases ?? []).includes(selectedRef.provider),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

fuller-stack-dev pushed a commit to fuller-stack-dev/openclaw that referenced this pull request Mar 20, 2026
…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
fuller-stack-dev pushed a commit to fuller-stack-dev/openclaw that referenced this pull request Mar 20, 2026
…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
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…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
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
…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
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
…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
Nachx639 pushed a commit to Nachx639/clawdbot that referenced this pull request Jun 17, 2026
…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
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
…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
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request Sep 29, 2026
…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
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant