It was 3:17 AM when my phone buzzed. Not a Telegram message from James — an error log from my OpenClaw agent. The primary model was returning 503s. The agent had ground to a halt at 2:44 AM and sat there for 33 minutes before the fallback chain kicked in and it recovered on its own.
That 33-minute gap taught me more about OpenClaw's model fallback system than any documentation had. Here's what actually happens when your primary provider chokes — and how to configure a fallback chain that saves you at 3 AM instead of failing silently.
What a Fallback Chain Actually Is
A fallback chain is an ordered list of models. OpenClaw tries them in sequence until one responds successfully. If your primary (say, Claude) is down, it doesn't just fail — it walks down the list.
The configuration looks something like this in your openclaw.json:
{
"model": "claude-sonnet-4-20250514",
"fallbacks": [
"claude-sonnet-4-20250514",
"gpt-4o",
"gemini-2.5-flash"
],
"provider": "openrouter"
}
But there's a subtlety most people miss: the fallback is per-call, not per-session. If a single tool call fails with a 503, OpenClaw retries that specific call with the next model in the chain — it doesn't abandon the whole session. This is the difference between a 30-second hiccup and a 33-minute outage.
The 3 AM Incident: What the Logs Actually Show
Here's the sequence from my agent's run log:
[02:44:07] Tool call 'browser' → anthropic: 503 Service Unavailable
[02:44:07] Falling back to gpt-4o
[02:44:08] Tool call 'browser' → openai/gpt-4o: 200 OK
[02:44:09] Session recovered. Continuing.
The agent didn't restart. It didn't lose context. It retried one tool call with a different model and kept going. That's the behavior you want.
The failure only became a 33-minute gap because I hadn't configured maxRetries correctly and the agent was spending too long waiting before attempting the fallback. The recovery was fast — the detection was slow.
Configuring Fast Fallbacks
The key settings that control fallback behavior:
{
"maxRetries": 3,
"retryDelayMs": 500,
"timeoutMs": 30000,
"model": "claude-sonnet-4-20250514",
"fallbacks": ["gpt-4o", "gemini-2.5-flash"]
}
maxRetries controls how many times OpenClaw retries the same model before moving to the next. retryDelayMs is the pause between retries. With the settings above, after a 503, OpenClaw waits 500ms, retries twice, then moves to the next model.
Here's the mistake I made: I had retryDelayMs: 5000 (5 seconds) and maxRetries: 5. That's up to 25 seconds per model. If you have 3 models and all are struggling, that's 75 seconds of waiting before the session gives up. In a production agent running overnight cron jobs, that compounds.
The fix:
{
"maxRetries": 2,
"retryDelayMs": 1000,
"timeoutMs": 20000
}
This gives each model 4 seconds to respond (2 retries × 1 second + 2 second initial timeout) before moving on. More aggressive, but for a 3 AM cron job, I'd rather have the agent try the next model quickly than sit there timing out slowly.
Monitoring: How to Know When Fallbacks Are Triggered
The fallback chain is only useful if you can see when it's being used. I added a simple log filter to my daily health check:
# Check for fallback events in recent agent logs
grep -i "fallback\|503\|502\|rate.limit" \
~/.openclaw/logs/agent-$(date +%Y-%m-%d).log \
| tail -20
If you see fallback events more than once a week, your primary model is unstable enough that you should reconsider your chain — or add a more reliable model as primary.
I also set up a Telegram alert for any log line containing "Falling back":
if "Falling back to" in log_line:
send_telegram_alert(
f"⚠️ Fallback triggered: {model_fallback_to}"
)
This gives me a ping when the chain activates, so I know the agent is degraded even if it recovers on its own.
The One Thing That Actually Works
The fallback chain is only as good as its weakest link. If you configure three models but one is consistently slow or rate-limited, your agent will still stall — it'll just stall on a different provider.
Test your fallback chain quarterly. Shut down your primary (or mock a 503) and watch how your agent behaves. Does it recover in under a minute? Does it notify you? Or does it sit there until someone checks at 9 AM?
My 3 AM incident turned a 33-minute gap into a 5-minute fix (add better monitoring). The agent was already doing the right thing — I just couldn't see it happening.
If you want the full OpenClaw configuration I run — including the fallback chain, timeout settings, and monitoring setup — it's in my book Why Is My OpenClaw Dumb? on Amazon ($9.99).
Top comments (0)