-
-
Notifications
You must be signed in to change notification settings - Fork 69.5k
[Bug]: ReferenceError: Cannot access 'ANTHROPIC_MODEL_ALIASES' before initialization on gateway start #45057
Description
Bug type
Crash (process/app exits or hangs)
Summary
The OpenClaw gateway fails to start with a ReferenceError: Cannot access 'ANTHROPIC_MODEL_ALIASES' before initialization error when any anthropic/* model ID is present in the agents.defaults.models block of openclaw.json.
The error occurs regardless of whether a short model ID (e.g. anthropic/claude-3-5-sonnet) or a full versioned ID (e.g. anthropic/claude-3-5-sonnet-20241022) is used.
Error Output:
Failed to read config at /Users/madrus/.openclaw/openclaw.json
ReferenceError: Cannot access 'ANTHROPIC_MODEL_ALIASES' before initialization
at normalizeAnthropicModelId (auth-profiles-Cm29uFmx.js:164837:3)
at normalizeProviderModelId (...:164840:40)
at normalizeModelRef (...:164853:12)
at parseModelRef (...:164864:10)
at applyContextPruningDefaults (...:7205:44)
at Object.loadConfig (...:16237:91)
Steps to reproduce
Add an anthropic/* model entry to agents.defaults.models in openclaw.json:
{
"agents": {
"defaults": {
"models": {
"anthropic/claude-3-5-sonnet": {
"alias": "sonnet",
"params": { "cacheRetention": "short" }
}
}
}
}
}then run openclaw gateway restart.
Expected behavior
The gateway starts normally with the Anthropic model registered as an alias.
Actual behavior
The gateway fails to start. The config cannot be read due to ANTHROPIC_MODEL_ALIASES being referenced before it is initialized in the loading sequence (applyContextPruningDefaults → parseModelRef → normalizeAnthropicModelId).
Root Cause
During config loading, applyContextPruningDefaults calls parseModelRef, which calls normalizeAnthropicModelId. At that point in the initialization sequence, ANTHROPIC_MODEL_ALIASES has not yet been defined, causing the reference error.
Workaround
Remove all anthropic/* entries from agents.defaults.models. Anthropic models can still be used as fallbacks by referencing them directly in agents.defaults.model.fallbacks without an alias:
{
"agents": {
"defaults": {
"model": {
"fallbacks": ["anthropic/claude-3-5-sonnet-20241022"]
},
"models": {}
}
}
}OpenClaw version
any latest version up to 2026.3.12
Operating system
macOS Tahoe 26.4
Install method
local install via curl command from the docs and openclaw update
Model
any anthropic model
Provider / routing chain
openclaw on localhost:18789
Config file / key location
No response
Additional provider/model setup details
No response
Logs, screenshots, and evidence
Failed to read config at /Users/madrus/.openclaw/openclaw.json
ReferenceError: Cannot access 'ANTHROPIC_MODEL_ALIASES' before initialization
at normalizeAnthropicModelId (auth-profiles-Cm29uFmx.js:164837:3)
at normalizeProviderModelId (...:164840:40)
at normalizeModelRef (...:164853:12)
at parseModelRef (...:164864:10)
at applyContextPruningDefaults (...:7205:44)
at Object.loadConfig (...:16237:91)Impact and severity
No response
Additional information
No response