> For the complete documentation index, see [llms.txt](https://www.openclawbook.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.openclawbook.xyz/en/ch07-model-configuration/7.2-fallback-chains-and-cost-optimization.md). Agents can also search and read this documentation through its [MCP server](https://www.openclawbook.xyz/~gitbook/mcp).

# 7.2 Fallback Chains and Cost Optimization

> **Generated by**: Claude Opus 5 (claude-opus-5\[1m]) **Token usage**: Input \~190,000 tokens, Output \~9,000 tokens (this section) **Source baseline**: `v2026.3.9` (`v2026.3.8-170-g665f67726`)

***

## 7.2.1 The Three-Tier Fallback Strategy

When a model call fails, OpenClaw degrades across three tiers before giving up (§16.5.4):

```
Tier 1  auth profile rotation (seconds)
        same model, next account
           ↓ every account for this model is exhausted
Tier 2  model fallback (within the turn)
        walk the fallbacks chain
           ↓ the chain is exhausted too
Tier 3  cooldown probing (30s throttle)
        test whether a cooling account has recovered
```

Configuring the middle tier:

```json5
{
  agents: {
    defaults: {
      model: {
        primary: "anthropic/claude-opus-4-6",
        fallbacks: [
          "anthropic/claude-sonnet-4-6",   // same provider, cheaper
          "openai/gpt-5.3",                 // different provider, different failure mode
        ],
      },
    },
  },
}
```

**Put a different provider in the chain, not just a different model.** If the fallback shares a provider with the primary, a provider-wide outage takes both out. The point of a fallback is a different failure mode.

Setting `fallbacks: []` explicitly disables fallback.

> **One rule worth knowing**: fallbacks are treated as **explicit user intent and are not filtered by the model allowlist** (§16.5.3). If you put it in the chain, OpenClaw assumes you meant it.

### When it does and doesn't switch

| Failure                 | Behavior                                                                                                     |
| ----------------------- | ------------------------------------------------------------------------------------------------------------ |
| Rate limit / overloaded | Rotate accounts first, then try sibling models under the same provider (**limits are usually model-scoped**) |
| Auth error              | **Skip that provider's models entirely** — the account is broken, another model won't help                   |
| Billing                 | Semi-persistent; a 30-second-throttled probe stays open in case you just topped up                           |
| Timeout                 | **Retry without charging the account**                                                                       |

### You get told, once

When degradation happens you get a notice — and **only on the turn it happens and the turn it recovers** (§14.5.7), not every turn afterward. Otherwise you'd see "you're on the backup model" on every reply until it recovered.

## 7.2.2 Model Discovery and Free Options

```bash
openclaw models list                  # everything configured
openclaw models status                # with reachability probes
openclaw models list --free           # free-tier models, where detectable
```

Several providers offer free tiers worth using for low-stakes work:

| Use                                 | Suggestion                                                             |
| ----------------------------------- | ---------------------------------------------------------------------- |
| Scheduled briefings, monitoring     | A cheap or free model — fetching and formatting doesn't need reasoning |
| Heartbeat checks                    | Same; configure `heartbeat.model` separately                           |
| Mail triage / classification        | Small model                                                            |
| Code review, architecture questions | Your best model                                                        |

## 7.2.3 Practical Cost Reduction

Ordered by how much they actually save.

### 1. Cut the tool set

**The single biggest lever** (§22.5, Appendix C.9). Tool schemas run around 30,000 characters (\~8k tokens) and are sent on **every** call in a turn.

```json5
{
  agents: {
    defaults: {
      tools: {
        profile: "messaging",       // a much smaller set
      },
    },
  },
}
```

Check what you're actually paying:

```
/context detail
```

The system prompt bill breaks out schema size specifically.

### 2. Assign models per task

```bash
# Scheduled jobs on a cheap model
openclaw cron add --schedule "0 8 * * *" --isolated --model "claude-haiku" ...
```

```json5
{
  heartbeat: { model: "claude-haiku" },   // heartbeats don't need a big model
}
```

A heartbeat every 30 minutes on an expensive model is a meaningful recurring cost for zero benefit.

### 3. Use `/new` more often

A fresh session is cheaper than a long one carrying unrelated history — every turn re-sends the accumulated context. When the topic changes, start over.

### 4. Understand prompt caching

Anthropic's prompt cache has a 5-minute TTL. Within that window, repeated context is much cheaper.

The practical implication: **a burst of related messages is cheaper than the same messages spread over an hour.** OpenClaw already factors the cache TTL into its pruning decisions (§17.6.2) — pruning only after the cache expires, since pruning inside the window would invalidate it and cost more than it saves.

### 5. Trim skills

Every loaded skill costs a description line in the system prompt (§6.2.4). Disabling ones you never use is small but free.

### Watching spend

```bash
openclaw usage status         # token usage
openclaw usage cost           # estimated cost
```

Per-session, `/status` shows the same for the current conversation.

***

## Section Summary

1. **Three degradation tiers**: auth profile rotation (seconds) → model fallback (within the turn) → cooldown probing (30s throttle).
2. **Put a different provider in the fallback chain**, not just a different model — a shared provider means a shared failure mode, defeating the point. Fallbacks are **explicit intent and bypass the model allowlist**.
3. **Switching behavior depends on the failure**: rate limits try sibling models (limits are usually model-scoped), auth errors skip the whole provider, billing keeps a probe channel open, and **timeouts retry without charging the account**.
4. **Degradation notices appear only on the turn it happens and the turn it recovers** — no per-turn spam.
5. **Cutting the tool set is the biggest cost lever** — schemas run \~8k tokens and are sent on every call; `/context detail` shows exactly what you're paying.
6. **Assign cheap models to scheduled jobs and heartbeats** — an expensive model checking every 30 minutes is a real recurring cost for no benefit.
7. **A burst of related messages is cheaper than the same messages spread out** because of the 5-minute prompt cache; OpenClaw already prunes only after cache expiry for exactly this reason.
