openclaw - ✅(Solved) Fix CLI backend model refs fail with Unknown model because provider runtime lookup ignores cliBackends [2 pull requests, 5 comments, 4 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#57326Fetched 2026-04-08 01:50:57
View on GitHub
Comments
5
Participants
4
Timeline
16
Reactions
0
Author
Timeline (top)
commented ×5cross-referenced ×4subscribed ×4mentioned ×1

When agents.defaults.model.primary is set to a CLI backend model such as claude-cli/claude-opus-4-6, OpenClaw can fail with Unknown model: claude-cli/claude-opus-4-6 even though the Anthropic plugin declares cliBackends: ["claude-cli"] and the Claude CLI backend itself is registered.

Root Cause

When agents.defaults.model.primary is set to a CLI backend model such as claude-cli/claude-opus-4-6, OpenClaw can fail with Unknown model: claude-cli/claude-opus-4-6 even though the Anthropic plugin declares cliBackends: ["claude-cli"] and the Claude CLI backend itself is registered.

Fix Action

Fix / Workaround

Verified local fix

I validated a local patch that:

  • treats plugin.cliBackends as owning ids in resolveOwningPluginIdsForProvider()
  • adds hookAliases: ["claude-cli"] to the Anthropic provider
  • adds hookAliases: ["codex-cli"] to the OpenAI Codex provider for the same class of bug

I can open a PR with the tested patch immediately.

PR fix notes

PR #57327: fix: route remaining cli-backed helper runs through CLI paths

Description (problem / solution / changelog)

Summary

Latest main already contains the original CLI backend ownership / isCliProvider() fix from #57326.

This PR is now only the remaining helper-path cleanup that latest main still lacks:

  • queued followup runs
  • models status --probe
  • LLM slug generation

Changes

  • route CLI-backed queued followups through runCliAgent()
  • keep queued CLI followups on the active runtime config and active session binding
  • route CLI-backed auth probes through runCliAgent()
  • keep CLI auth probes tiny and thinking-off
  • route CLI-backed slug generation through runCliAgent()
  • preserve the latest-main slug-timeout behavior while adding CLI dispatch
  • add focused regression coverage for followups, probe helpers, and slug generation

Verification

pnpm test -- src/auto-reply/reply/followup-runner.test.ts src/commands/models/list.probe.cli.test.ts src/commands/models/list.probe.targets.test.ts src/commands/models/list.probe.test.ts src/hooks/llm-slug-generator.test.ts src/agents/model-selection.test.ts src/plugins/providers.test.ts
pnpm build

Fixes #57326

Changed files

  • src/auto-reply/reply/followup-runner.test.ts (modified, +397/-6)
  • src/auto-reply/reply/followup-runner.ts (modified, +87/-3)
  • src/commands/models/list.probe.cli.test.ts (added, +213/-0)
  • src/commands/models/list.probe.ts (modified, +49/-22)
  • src/hooks/llm-slug-generator.test.ts (modified, +56/-4)
  • src/hooks/llm-slug-generator.ts (modified, +32/-15)

PR #58386: fix: emit cli-backends.runtime as standalone build entry

Description (problem / solution / changelog)

Fixes #57326

What's broken

The claude-cli provider (and all CLI backend providers) fails with "Unknown model" errors on every request:

⚠️ Agent failed before reply: All models failed (5):
  claude-cli/claude-sonnet-4-6: Unknown model (model_not_found)
  claude-cli/claude-opus-4-6: Unknown model (model_not_found)
  ...

This affects anyone who configured the Anthropic Claude CLI auth method via openclaw agents add or openclaw configure --section model.

How to reproduce

  1. openclaw agents add main → Anthropic → "Anthropic Claude CLI"
  2. Send any message via TUI, Telegram, Slack, or openclaw agent
  3. Every request fails with Unknown model: claude-cli/...

Root cause

Two independent issues prevent claude-cli from working:

1. CLI backend routing (commit 1): The CLI backends runtime module is not emitted as a standalone file by the bundler — it gets inlined into another chunk. At runtime, isCliProvider() silently fails to load the module and always returns false, so claude-cli requests are sent to the embedded inference runner instead of the CLI runner subprocess.

2. Provider hook resolution (commit 2): Even when the model resolver runs for claude-cli, the plugin ownership lookup and provider runtime hooks don't fire because claude-cli is only registered as a cliBackend, not as a provider or hookAlias on the Anthropic plugin. This was independently diagnosed in #57326 (comment).

Fix

Commit 1 — fix CLI backend routing:

  • Register the CLI backends runtime as a standalone build entry (matching how provider-runtime.runtime is already registered)
  • Fix the require() resolution pattern to anchor to the correct file location
  • Add a build-smoke assertion to prevent silent regression

Commit 2 — fix provider hook resolution (credit: #57326 comment):

  • Add claude-cli as a hookAlias on the Anthropic provider so matchesProviderId() and runtime hooks fire
  • Include cliBackends in resolveOwningPluginIdsForProvider() so the plugin registry maps CLI backend IDs back to their owning plugin

May also partially address #57907.

Changed files

  • extensions/anthropic/index.ts (modified, +2/-0)
  • scripts/test-built-plugin-singleton.mjs (modified, +8/-0)
  • src/agents/model-selection.ts (modified, +8/-1)
  • src/plugins/providers.ts (modified, +8/-2)
  • tsdown.config.ts (modified, +1/-0)

Code Example

Unknown model: claude-cli/claude-opus-4-6

---

corepack pnpm exec vitest run src/plugins/providers.test.ts src/plugins/provider-runtime.test.ts
RAW_BUFFERClick to expand / collapse

Summary

When agents.defaults.model.primary is set to a CLI backend model such as claude-cli/claude-opus-4-6, OpenClaw can fail with Unknown model: claude-cli/claude-opus-4-6 even though the Anthropic plugin declares cliBackends: ["claude-cli"] and the Claude CLI backend itself is registered.

Repro

  1. Configure:
    • agents.defaults.model.primary = "claude-cli/claude-opus-4-6"
    • agents.defaults.models = { "claude-cli/claude-opus-4-6": {} }
    • agents.defaults.cliBackends.claude-cli.command = "/path/to/claude"
  2. Ensure Claude CLI is installed and logged in with claude auth login.
  3. Restart the gateway.
  4. Send a message through a real surface or run an agent turn.

Actual

OpenClaw fails before reply with:

Unknown model: claude-cli/claude-opus-4-6

Expected

The Anthropic plugin should own claude-cli runtime hooks, so claude-cli/claude-opus-4-6 should resolve and run through the registered CLI backend.

Source findings

  • src/plugins/provider-runtime.ts:174 resolves the owning plugin ids for the requested provider and then tries to match the provider id against loaded provider plugins.
  • src/plugins/providers.ts:73 currently treats plugin.providers as ownership, but not plugin.cliBackends.
  • extensions/anthropic/index.ts:352 registers the Claude CLI backend, but the provider plugin itself is still only identified as anthropic, so runtime hook lookup for claude-cli never lands on the Anthropic provider hooks.
  • src/gateway/server-startup.ts:53 also does a static-only warmup with skipProviderRuntimeHooks: true, which makes the startup warning noisier, but the user-facing failure here is the runtime ownership mismatch.

Verified local fix

I validated a local patch that:

  • treats plugin.cliBackends as owning ids in resolveOwningPluginIdsForProvider()
  • adds hookAliases: ["claude-cli"] to the Anthropic provider
  • adds hookAliases: ["codex-cli"] to the OpenAI Codex provider for the same class of bug

Targeted verification passed:

corepack pnpm exec vitest run src/plugins/providers.test.ts src/plugins/provider-runtime.test.ts

Result:

  • 2 test files passed
  • 25 tests passed

I can open a PR with the tested patch immediately.

extent analysis

Fix Plan

To resolve the issue, we need to update the resolveOwningPluginIdsForProvider() function to treat plugin.cliBackends as owning ids. We also need to add hookAliases to the Anthropic and OpenAI Codex providers.

Step-by-Step Solution

  1. Update resolveOwningPluginIdsForProvider():
    • In src/plugins/provider-runtime.ts, modify the resolveOwningPluginIdsForProvider() function to include plugin.cliBackends in the ownership check.
    function resolveOwningPluginIdsForProvider(providerId: string) {
      // ... existing code ...
      const owningPluginIds = [];
      for (const plugin of plugins) {
        if (plugin.providers.includes(providerId) || plugin.cliBackends.includes(providerId)) {
          owningPluginIds.push(plugin.id);
        }
      }
      return owningPluginIds;
    }
  2. Add hookAliases to Anthropic provider:
    • In extensions/anthropic/index.ts, add hookAliases: ["claude-cli"] to the Anthropic provider.
    const anthropicProvider = {
      // ... existing code ...
      hookAliases: ["claude-cli"],
    };
  3. Add hookAliases to OpenAI Codex provider:
    • In the OpenAI Codex provider file, add hookAliases: ["codex-cli"].
    const codexProvider = {
      // ... existing code ...
      hookAliases: ["codex-cli"],
    };

Verification

To verify the fix, run the following tests:

corepack pnpm exec vitest run src/plugins/providers.test.ts src/plugins/provider-runtime.test.ts

This should result in 2 test files passing with 25 tests passed.

Extra Tips

  • Make sure to test the changes thoroughly to ensure that the fix does not introduce any regressions.
  • Consider adding additional tests to cover the updated resolveOwningPluginIdsForProvider() function and the hookAliases feature.

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