openclaw - 💡(How to fix) Fix [Bug] Custom provider models without explicit `provider` field fail `resolveGatewayModelSupportsImages` — images offloaded as text [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#73858Fetched 2026-04-29 06:14:11
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
0
Author
Timeline (top)
closed ×1commented ×1

When a custom model is configured under models.providers.<name>.models[] without an explicit "provider" field on the model entry, resolveGatewayModelSupportsImages fails to find the model in the catalog. This causes gateway to treat the model as text-only and offload all image attachments instead of sending them as inline image blocks.

Root Cause

In session-utils-r05OsxB5.js (compiled), function resolveGatewayModelSupportsImages:

const modelEntry = (await params.loadGatewayModelCatalog()).find((entry) =>
  entry.id === params.model && (!params.provider || entry.provider === params.provider)
);

Model entries from config do not inherit the provider key and the JSON schema (models.providers.*.models.*) has additionalProperties: false, so adding "provider" to a model entry is stripped on gateway restart.

Result:

  • entry.provider = undefined
  • params.provider = "kimi-coding" (or whatever provider key is)
  • undefined === "kimi-coding"false
  • modelEntry = undefinedreturn false → images offloaded

Fix Action

Fix / Workaround

Workaround (Local Patch)

Patch resolveGatewayModelSupportsImages in compiled bundle:

Option C: Make the provider comparison in resolveGatewayModelSupportsImages tolerant of missing entry.provider (as in workaround above).

Code Example

const modelEntry = (await params.loadGatewayModelCatalog()).find((entry) =>
  entry.id === params.model && (!params.provider || entry.provider === params.provider)
);

---

{
  "models": {
    "mode": "replace",
    "providers": {
      "kimi-coding": {
        "baseUrl": "https://agent-gw.kimi.com/coding",
        "apiKey": "sk-...",
        "api": "anthropic-messages",
        "models": [
          {
            "id": "k2p5",
            "name": "k2p5",
            "reasoning": true,
            "input": ["text", "image"],
            "contextWindow": 131072,
            "maxTokens": 32768
          }
        ]
      }
    }
  },
  "agents": {
    "defaults": {
      "model": { "primary": "kimi-coding/k2p5" }
    }
  }
}

---

- entry.id === params.model && (!params.provider || entry.provider === params.provider)
+ entry.id === params.model && (!params.provider || !entry.provider || entry.provider === params.provider)
RAW_BUFFERClick to expand / collapse

[Bug] Custom provider models without explicit provider field fail resolveGatewayModelSupportsImages — images offloaded as text

Summary

When a custom model is configured under models.providers.<name>.models[] without an explicit "provider" field on the model entry, resolveGatewayModelSupportsImages fails to find the model in the catalog. This causes gateway to treat the model as text-only and offload all image attachments instead of sending them as inline image blocks.

Root Cause

In session-utils-r05OsxB5.js (compiled), function resolveGatewayModelSupportsImages:

const modelEntry = (await params.loadGatewayModelCatalog()).find((entry) =>
  entry.id === params.model && (!params.provider || entry.provider === params.provider)
);

Model entries from config do not inherit the provider key and the JSON schema (models.providers.*.models.*) has additionalProperties: false, so adding "provider" to a model entry is stripped on gateway restart.

Result:

  • entry.provider = undefined
  • params.provider = "kimi-coding" (or whatever provider key is)
  • undefined === "kimi-coding"false
  • modelEntry = undefinedreturn false → images offloaded

Reproduction

Config (openclaw.json)

{
  "models": {
    "mode": "replace",
    "providers": {
      "kimi-coding": {
        "baseUrl": "https://agent-gw.kimi.com/coding",
        "apiKey": "sk-...",
        "api": "anthropic-messages",
        "models": [
          {
            "id": "k2p5",
            "name": "k2p5",
            "reasoning": true,
            "input": ["text", "image"],
            "contextWindow": 131072,
            "maxTokens": 32768
          }
        ]
      }
    }
  },
  "agents": {
    "defaults": {
      "model": { "primary": "kimi-coding/k2p5" }
    }
  }
}

Note: models.providers.kimi-coding.models[0] has no "provider" field — and it cannot have one because of schema validation (additionalProperties: false).

Steps

  1. Configure provider and model as above
  2. Start gateway
  3. Send an image attachment via webchat or any inbound channel
  4. Gateway logs: Offloaded image for text-only model
  5. The model receives text "An image file was uploaded..." instead of an image block

Expected Behavior

Gateway should find the model and recognize it as image-capable, passing the image as an inline image block (Anthropic Messages image content type).

Actual Behavior

Gateway offloads the image because resolveGatewayModelSupportsImages returns false.

Workaround (Local Patch)

Patch resolveGatewayModelSupportsImages in compiled bundle:

- entry.id === params.model && (!params.provider || entry.provider === params.provider)
+ entry.id === params.model && (!params.provider || !entry.provider || entry.provider === params.provider)

This makes the provider check on the entry optional.

Environment

  • OpenClaw version: latest compiled bundle
  • Provider: kimi-coding via anthropic-messages API
  • Model: k2p5 with input: ["text", "image"]

Suggested Fix (Upstream)

Option A: Allow "provider" field in model schema so it can be explicitly set and not stripped.

Option B: Auto-populate entry.provider from the parent provider key when loading the catalog (since the provider key is already known at load time).

Option C: Make the provider comparison in resolveGatewayModelSupportsImages tolerant of missing entry.provider (as in workaround above).

extent analysis

TL;DR

The most likely fix is to modify the resolveGatewayModelSupportsImages function to make the provider comparison tolerant of missing entry.provider or to auto-populate entry.provider from the parent provider key.

Guidance

  • Verify that the issue is caused by the missing "provider" field in the model entry by checking the gateway logs for the "Offloaded image for text-only model" message.
  • Consider applying the local patch to resolveGatewayModelSupportsImages as a temporary workaround.
  • To fix the issue upstream, choose one of the suggested options: allow the "provider" field in the model schema, auto-populate entry.provider, or make the provider comparison tolerant of missing entry.provider.
  • Test the fix by sending an image attachment via webchat or any inbound channel and verifying that the image is passed as an inline image block.

Example

The local patch can be applied as follows:

- entry.id === params.model && (!params.provider || entry.provider === params.provider)
+ entry.id === params.model && (!params.provider || !entry.provider || entry.provider === params.provider)

This change makes the provider check on the entry optional.

Notes

The issue is specific to custom provider models without an explicit "provider" field, and the fix should be applied carefully to avoid introducing other issues.

Recommendation

Apply the workaround by patching resolveGatewayModelSupportsImages to make the provider comparison tolerant of missing entry.provider, as this is a relatively simple and non-invasive change.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Bug] Custom provider models without explicit `provider` field fail `resolveGatewayModelSupportsImages` — images offloaded as text [1 comments, 2 participants]