Skip to content

[Bug]: /btw fails with "Unknown model" for anthropic/* aliases routed via agentRuntime: claude-cli (resolver path divergence from main agent loop) #92168

Description

@wangwllu

Bug type

Regression (worked before, now fails) — the agents.defaults.models shape with agentRuntime.id: claude-cli is the post-5.12 recommended way to express "this canonical alias resolves through the CLI binary, not direct API" (see #82314), but /btw was never updated to honor it.

Beta release blocker

No

Summary

/btw throws Unknown model: <provider>/<modelId> when the agent's primary model is configured as a canonical alias (e.g. anthropic/claude-opus-4-7) routed via agents.defaults.models[].agentRuntime.id = "claude-cli", and the agent's discovered models.json does not contain a bare anthropic provider entry. The same model id works fine for the main turn. Repros 4/4 on 2026.6.5 (5181e4f).

Steps to reproduce

  1. ~/.openclaw/openclaw.json:
    "agents.defaults": {
      "model": { "primary": "anthropic/claude-opus-4-7" },
      "models": {
        "anthropic/claude-opus-4-7": { "agentRuntime": { "id": "claude-cli" } }
      }
    }
  2. ~/.openclaw/agents/main/agent/models.json does not contain an anthropic provider entry. (Either no API key has been registered for direct Anthropic, or the agent's only registered Anthropic-compatible providers are third-party proxies under different provider keys.)
  3. Send a normal turn — works (the claude-cli runtime takes over via cli_runtime_passthrough_openclaw).
  4. Send /btw <any question> in the same session.

Expected behavior

/btw resolves the same anthropic/claude-opus-4-7 ref the main turn just used and answers the side question. The configured agentRuntime.id = claude-cli should route BTW down the same cli_runtime_passthrough_openclaw path the main agent uses, instead of failing on a strict registry lookup that ignores the alias.

Actual behavior

⚠️ /btw failed: Unknown model: anthropic/claude-opus-4-7

Thrown at src/agents/btw.ts:267 from the resolveModelWithRegistry call at btw.ts:260.

OpenClaw version

2026.6.5 (5181e4f)

Operating system

macOS 15.4 (Darwin 25.4.0, arm64)

Install method

npm global

Model

anthropic/claude-opus-4-7 (with agentRuntime.id: claude-cli)

Provider / routing chain

openclaw → claude-cli runtime → claude binary

Additional provider/model setup details

  • agents.defaults.models declares the canonical anthropic/* alias with agentRuntime: { id: "claude-cli" } — the dual-route shape recommended by [Feature]: Per-alias agentRuntime override to support dual-route model configurations (Anthropic CLI + API) #82314.
  • ~/.openclaw/agents/main/agent/models.json only contains custom third-party Anthropic-compatible providers (different provider keys, e.g. my-proxy-anthropic); no bare anthropic provider is auto-discovered, by design — there is no direct Anthropic API key on this host, and the claude-cli runtime is supposed to handle it.

Logs, screenshots, and evidence

⚠️ /btw failed: Unknown model: anthropic/claude-opus-4-7

Resolver-path divergence (read in 2026.6.5 source):

  • Main turn (works)src/agents/embedded-agent-runner/run.ts:710-790 builds a multi-candidate provider list (selectedRuntimeProvider + canonical provider) and calls resolveModelAsync with allowBundledStaticCatalogFallback: pluginHarnessOwnsTransport. On miss it re-runs ensureOpenClawModelsJson and retries. Harness selection at src/agents/harness/selection.ts:181-191 honors cli_runtime_passthrough_openclaw so agentRuntime: claude-cli aliases are accepted as bare anthropic/* refs.
  • BTW (fails)src/agents/btw.ts:343 runs selectAgentHarness (correctly returns the OpenClaw harness via cli_runtime_passthrough_openclaw); because harness.runSideQuestion is undefined, control falls through to btw.ts:409resolveRuntimeModelresolveModelWithRegistry at btw.ts:260. That call uses only the disk-discovered modelRegistry (single provider list, no selectedRuntimeProvider candidate, no bundled-catalog fallback). The bare anthropic provider isn't on disk → Unknown model at btw.ts:267.

The error message is also thinner than the main path produces — resolveModelAsync formats a richer "Found agents.defaults.models[...] but no matching models.providers[...]" message via buildUnknownModelError (embedded-agent-runner/model.ts:1383-1393); BTW's primitive path skips that.

Impact and severity

  • Affected: Any user with agents.defaults.models[<canonical-alias>].agentRuntime.id set to a CLI runtime alias (the shape [Feature]: Per-alias agentRuntime override to support dual-route model configurations (Anthropic CLI + API) #82314 is asking for, and the only way to express "use the CLI binary, not the direct API" since canonical-namespace consolidation in 5.12). Main turns work; /btw is broken on every invocation.
  • Severity: Annoying, blocks workflow — /btw is unusable; main turns continue to work, so the blast radius is limited to that one command.
  • Frequency: 4/4 observed (deterministic given the config shape).
  • Consequence: No side-question access in active sessions. Workaround forces users to either drop the canonical-alias indirection or skip /btw.

Additional information

Metadata

Metadata

Assignees

Labels

P2Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

Type

No type

Fields

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions