Caricamento in corso...
Caricamento in corso...
Last synced: Today, 22:00
Technical reference for the OpenClaw framework. Real-time synchronization with the official documentation engine.
Use this file to discover all available pages before exploring further.
OpenClaw handles failures in two stages:
agents.defaults.model.fallbacksThis doc explains the runtime rules and the data that backs them.
For a normal text run, OpenClaw evaluates candidates in this order:
This is intentionally narrower than "save and restore the whole session". The reply runner only persists the model-selection fields it owns for fallback:
providerOverridemodelOverridemodelOverrideSourceauthProfileOverrideauthProfileOverrideSourceauthProfileOverrideCompactionCountThat prevents a failed fallback retry from overwriting newer unrelated session mutations such as manual
/modelOpenClaw separates the selected provider/model from why it was selected. That source controls whether the fallback chain is allowed:
agents.defaults.model.primaryagents.defaults.model.fallbacksagents.list[].modelfallbacksfallbacks: []providerOverridemodelOverridemodelOverrideSource: "auto"/new/resetsessions.reset/modelsession_status(model=...)sessions.patchmodelOverrideSource: "user"modelOverridemodelOverrideSourcepayload.model--modelpayload.fallbackspayload.fallbacks: []OpenClaw uses auth profiles for both API keys and OAuth tokens.
~/.openclaw/agents/<agentId>/agent/auth-profiles.json~/.openclaw/agent/auth-profiles.json~/.openclaw/agents/<agentId>/agent/auth-state.jsonauth.profilesauth.order~/.openclaw/credentials/oauth.jsonauth-profiles.jsonMore detail: OAuth
Credential types:
type: "api_key"{ provider, key }type: "oauth"{ provider, access, refresh, expires, email? }projectIdenterpriseUrlOAuth logins create distinct profiles so multiple accounts can coexist.
provider:defaultprovider:<email>google-antigravity:user@gmail.comProfiles live in
~/.openclaw/agents/<agentId>/agent/auth-profiles.jsonprofilesWhen a provider has multiple profiles, OpenClaw chooses an order like this:
If no explicit order is configured, OpenClaw uses a round‑robin order:
usageStats.lastUsedOpenClaw pins the chosen auth profile per session to keep provider caches warm. It does not rotate on every request. The pinned profile is reused until:
/new/resetManual selection via
/model …@<profileId>If you have both an OAuth profile and an API key profile for the same provider, round‑robin can switch between them across messages unless pinned. To force a single profile:
auth.order[provider] = ["provider:profileId"]/model …When a profile fails due to auth/rate-limit errors (or a timeout that looks like rate limiting), OpenClaw marks it in cooldown and moves to the next profile.
Cooldowns use exponential backoff:
State is stored in
auth-state.jsonusageStatsjson{ "usageStats": { "provider:profile": { "lastUsed": 1736160000000, "cooldownUntil": 1736160600000, "errorCount": 2 } } }
Billing/credit failures (for example "insufficient credits" / "credit balance too low") are treated as failover-worthy, but they're usually not transient. Instead of a short cooldown, OpenClaw marks the profile as disabled (with a longer backoff) and rotates to the next profile/provider.
Meanwhile temporary
402rate_limitweekly usage limit exhausteddaily limit reached, resets tomorroworganization spending limit exceededState is stored in
auth-state.jsonjson{ "usageStats": { "provider:profile": { "disabledUntil": 1736178000000, "disabledReason": "billing" } } }
Defaults:
If all profiles for a provider fail, OpenClaw moves to the next model in
agents.defaults.model.fallbacksempty_responseno_error_detailsUnknown error (no error details in response)unclassifiedOverloaded and rate-limit errors are handled more aggressively than billing cooldowns. By default, OpenClaw allows one same-provider auth-profile retry, then switches to the next configured model fallback without waiting. Provider-busy signals such as
ModelNotReadyExceptionauth.cooldowns.overloadedProfileRotationsauth.cooldowns.overloadedBackoffMsauth.cooldowns.rateLimitedProfileRotationsWhen a run starts from the configured default primary, a cron job primary, an agent primary with explicit fallbacks, or an auto-selected fallback override, OpenClaw can walk the matching configured fallback chain. Agent primaries without explicit fallbacks and explicit user selections (for example
/model ollama/qwen3.5:27bsessions.patchOpenClaw builds the candidate list from the currently requested
provider/modelWhen every auth profile for a provider is already in cooldown, OpenClaw does not automatically skip that provider forever. It makes a per-candidate decision:
Session model changes are shared state. The active runner,
/modelThat means fallback retries have to coordinate with live model switching:
/modelsession_status(model=...)sessions.patchagents.defaults.model.fallbacks/new/resetsessions.reset/statusThis prevents the classic race:
The persisted fallback override closes that window, and the narrow rollback keeps newer manual or runtime session changes intact.
runWithModelFallback(...)rate_limitoverloadedbillingauthmodel_not_foundStructured
model_fallback_decisionfallbackStep*fallbackStepFromModelfallbackStepToModelfallbackStepFromFailureReasonfallbackStepFromFailureDetailfallbackStepFinalOutcomeWhen every candidate fails, OpenClaw throws
FallbackSummaryErrorThat cooldown summary is model-aware:
See Gateway configuration for:
auth.profilesauth.orderauth.cooldowns.billingBackoffHoursauth.cooldowns.billingBackoffHoursByProviderauth.cooldowns.billingMaxHoursauth.cooldowns.failureWindowHoursauth.cooldowns.overloadedProfileRotationsauth.cooldowns.overloadedBackoffMsauth.cooldowns.rateLimitedProfileRotationsagents.defaults.model.primaryagents.defaults.model.fallbacksagents.defaults.imageModelSee Models for the broader model selection and fallback overview.
© 2024 TaskFlow Mirror
Powered by TaskFlow Sync Engine