-
-
Notifications
You must be signed in to change notification settings - Fork 52.6k
Description
Summary
When configuring
openclaw.json
, if a user specifies global default models in agents.defaults.model but omits the model block in a specific agent's entry within agents.list (e.g., the main agent), embedded background agents (like the slug-generator used for session memory filenames) fail to inherit the global defaults.
Instead, they silently fall back to a hardcoded DEFAULT_MODEL = "claude-opus-4-6" using the anthropic provider. This leads to unexpected gateway hangs and API key errors during basic operations like creating a new session /new. Furthermore, this internal Anthropic request ignores any custom baseUrl configured by the user for the anthropic provider, forcing a request to the official Anthropic API.
Steps to reproduce
In
openclaw.json
, configure a local or alternative provider (e.g., local or bailian).
Set the global default model in agents.defaults.model.primary to your local model.
In agents.list, define the main agent but do not include a model configuration block for it.
Start the gateway (openclaw gateway start).
Open a channel (like Telegram or TUI) and trigger a new session (e.g., typing /new).
Observe the error in
gateway.err.log
.
Expected behavior
resolveAgentModelPrimary should intelligently fall back to agents.defaults.model when an individual agent in agents.list lacks a specific model override. The embedded agents should inherit the user's globally configured default models rather than a hardcoded Anthropic model.
Actual behavior
The gateway fails to generate the session slug and blocks the channel. In gateway.err.log
, you will see:
[llm-slug-generator] Failed to generate slug: FailoverError: No API key found for provider "anthropic". Auth store: [...]
If you attempt to "fix" this by adding an auth profile for anthropic with a fake key, the request bypasses any custom baseUrl in openclaw.json
and hits the real Anthropic API, resulting in:
[llm-slug-generator] Failed to generate slug: FailoverError: HTTP 401 authentication_error: invalid x-api-key (request_id: req_***)
Root Cause Analysis
In agent-scope.ts, the function resolveAgentModelPrimary(cfg, agentId) only checks resolveAgentConfig(cfg, agentId)?.model. If omitted, it returns undefined instead of looking up cfg.agents?.defaults?.model.
When the model parameter is unresolved, runEmbeddedPiAgent falls back to the system's DEFAULT_MODEL parameter, which is hardcoded downstream to "claude-opus-4-6" (anthropic provider).
The auth module attempts to resolve an API key for Anthropic. If missing, it crashes the background task. If a fake key is provided, the API request ignores user-defined custom proxy domains for the anthropic provider.
OpenClaw version
2026.2.22-2
Operating system
macOS 26.3 (25D125)
Install method
npm global
Logs, screenshots, and evidence
Impact and severity
No response
Additional information
No response