* refactor: extract agent core package Introduce packages/agent-core as the OpenClaw-owned home for reusable agent loop, harness, session, prompt, and runtime dependency contracts. * refactor: extract shared llm runtime Move provider model registries, stream wrappers, OAuth helpers, and LLM utilities into src/llm with plugin-sdk barrels instead of depending on the old embedded runtime layout. * refactor: remove pi runtime internals Rename remaining Pi-shaped agent surfaces to OpenClaw agent runtime names, delete obsolete Pi docs and package graph checks, and add the third-party notice for incorporated code. * refactor: tighten agent session runtime Make agent-core/runtime dependencies explicit, consolidate compaction and session transcript helpers, and move model/session helpers behind OpenClaw-owned contracts. * refactor: remove static model and pi auth paths Drop static model catalogs and Pi auth bridges, move model/provider facts to manifest-owned runtime contracts, and harden internal embedded-agent utilities. * refactor: remove legacy provider compat paths * docs: remove agent parity notes * fix: skip provider wildcard metadata parsing * refactor: share session extension sdk loading * refactor: inline acpx proxy error formatter * refactor: fold edit recovery into edit tool * fix: accept extension batch separator * test: align startup provider plugin expectations * fix: restore provider-scoped release discovery * test: align static asset packaging expectations * fix: run static provider catalogs during scoped discovery * fix: add provider entry catalogs for scoped live discovery * fix: load lightweight provider catalog entries * fix: refresh provider-scoped plugin metadata * fix: keep provider catalog entries on release live path * fix: keep static manifest models in release live checks * fix: harden release model discovery * fix: reduce OpenAI live cache probe reasoning * fix: disable OpenAI cache probe reasoning * ci: extend OpenAI gateway live timeout * fix: extend live gateway model budget * fix: stabilize release validation regressions * fix: honor provider aliases in model rows * fix: stabilize release validation lanes * fix: stabilize release memory qa * ci: stabilize release validation lanes * ci: prefer ipv4 for live docker node calls * fix: restore shared tool-call stream wrapper * ci: remove legacy pi test shard alias * fix: clean up embedded agent test drift * fix: stabilize runtime alias status * fix: clean up embedded agent ci drift * fix: restore release ci invariants * fix: clean up post-rebase runtime drift * fix: restore release ci checks * fix: restore release ci after rebase * fix: remove stale pi runtime path * test: align compaction runtime expectations * test: update plugin prerelease expectations * fix: handle claude live tool approvals * fix: stabilize release validation gates * fix: finish agent runtime import * test: finish post-rebase agent runtime mocks * fix: keep codex compaction native * fix: stabilize codex app-server hook tests * test: isolate codex diagnostic active run * test: remove codex diagnostic completion race # Conflicts: # extensions/codex/src/app-server/run-attempt.test.ts * ci: fix full release manifest performance run id * refactor: narrow llm plugin sdk boundary * chore: drop generated google boundary stamps * fix: repair rebase fallout * fix: clean up rebased runtime references * fix: decode codex jwt payloads as base64url * fix: preserve shipped pi runtime alias * fix: add scoped sdk virtual modules * fix: decode llm codex oauth jwt as base64url * fix: avoid stale vertex adc negative cache * fix: harden tool arg decoding and codeql path * fix: keep vertex adc negative checks live * refactor: consolidate codex jwt and edit helpers * fix: await codex oauth node runtime imports * fix: preserve sdk tool and notice contracts * fix: preserve shipped compat config boundaries * fix: align codex oauth callback host * fix: terminate agent-core loop streams on failure * fix: keep codex oauth callback alive during fallback * ci: include session tools in critical codeql scans * fix: keep Cloudflare Anthropic provider auth header * docs: redirect legacy pi runtime pages * fix: honor bundled web provider compat discovery * fix: protect session output spill files * fix: keep legacy agent dir env blocked * fix: contain auto-discovered skill symlinks * fix: harden agent core sdk proxy surfaces * fix: restore approval reaction sdk compat * fix: keep live docker runs bounded * fix: keep codex oauth redirect host aligned * fix: resolve post-rebase agent runtime drift * fix: redact anthropic oauth parse failures * fix: preserve responses strict tool shaping * fix: repair agent runtime rebase cleanup * docs: redirect retired parity pages * fix: bound auto-discovered resources to roots * fix: repair post-rebase agent test drift * fix: preserve bundled provider allowlist migration * fix: preserve manifest-owned provider aliases * fix: declare photon image dependency * fix: keep provider headers out of proxy body * fix: preserve shipped env aliases * fix: refresh control ui i18n generated state * fix: quote read fallback paths * fix: preview edits through configured backend * test: satisfy core test typecheck * fix: preserve ZAI usage auth fallback * test: repair codex diagnostic test * fix: repair agent runtime rebase drift * test: finish embedded runner import rename * fix: repair agent runtime rebase integrations * test: align compaction oauth fallback expectations * fix: allow sdk-auth session models * fix: update doctor tool schema import * fix: preserve bedrock plugin region * fix: stream harmony-like prose immediately * ci: include session runtime in codeql shards * fix: repair latest rebase integrations * fix: honor explicit codex websocket transport * fix: keep openai-compatible credentials provider-scoped * fix: refresh sdk api baseline after rebase * fix: route cli runtime aliases through openclaw harness * test: rename stale harness mock expectation * test: rename embedded agent overflow calls * test: clean embedded auth test wording * test: use openclaw stream types in deepinfra cache test * fix: refresh sdk api baseline on latest main * fix: honor bundled discovery compat allowlists * fix: refresh sdk api baseline after latest rebase * fix: remove stale rebase imports * test: rename stale model catalog mock * test: mock renamed doctor runtime modules * fix: map canonical kimi env auth * fix: use internal model registry in bench script * fix: migrate deepinfra provider catalog entry * fix: enforce builtin tool suppression * fix: route compaction auth and proxy payloads safely * refactor: prune unused llm registry leftovers * test: update codex hooks session import * test: fix model picker ci coverage * test: align model picker auth mock types
19 KiB
summary, read_when, title, sidebarTitle
| summary | read_when | title | sidebarTitle | |||
|---|---|---|---|---|---|---|
| Models CLI: list, set, aliases, fallbacks, scan, status |
|
Models CLI | Models CLI |
Model refs choose a provider and model. They do not usually choose the low-level agent runtime. OpenAI agent refs are the main exception: openai/gpt-5.5 runs through the Codex app-server runtime by default on the official OpenAI provider. Explicit runtime overrides belong on provider/model policy, not on the whole agent or session. In Codex runtime mode, the openai/gpt-* ref does not imply API-key billing; auth can come from a Codex account or openai-codex auth profile. See Agent runtimes.
How model selection works
OpenClaw selects models in this order:
`agents.defaults.model.primary` (or `agents.defaults.model`). `agents.defaults.model.fallbacks` (in order). Auth failover happens inside a provider before moving to the next model. - `agents.defaults.models` is the allowlist/catalog of models OpenClaw can use (plus aliases). Use `provider/*` entries to limit visible providers while keeping provider discovery dynamic. - `agents.defaults.imageModel` is used **only when** the primary model can't accept images. - `agents.defaults.pdfModel` is used by the `pdf` tool. If omitted, the tool falls back to `agents.defaults.imageModel`, then the resolved session/default model. - `agents.defaults.imageGenerationModel` is used by the shared image-generation capability. If omitted, `image_generate` can still infer an auth-backed provider default. It tries the current default provider first, then the remaining registered image-generation providers in provider-id order. If you set a specific provider/model, also configure that provider's auth/API key. - `agents.defaults.musicGenerationModel` is used by the shared music-generation capability. If omitted, `music_generate` can still infer an auth-backed provider default. It tries the current default provider first, then the remaining registered music-generation providers in provider-id order. If you set a specific provider/model, also configure that provider's auth/API key. - `agents.defaults.videoGenerationModel` is used by the shared video-generation capability. If omitted, `video_generate` can still infer an auth-backed provider default. It tries the current default provider first, then the remaining registered video-generation providers in provider-id order. If you set a specific provider/model, also configure that provider's auth/API key. - Per-agent defaults can override `agents.defaults.model` via `agents.list[].model` plus bindings (see [Multi-agent routing](/concepts/multi-agent)).Selection source and fallback behavior
The same provider/model can mean different things depending on where it came from:
- Configured defaults (
agents.defaults.model.primaryand agent-specific primaries) are the normal starting point and useagents.defaults.model.fallbacks. - Auto fallback selections are temporary recovery state. They are stored with
modelOverrideSource: "auto"so later turns can keep using the fallback chain without probing a known-bad primary every time; OpenClaw periodically probes the original primary again, clears the auto selection when it recovers, and announces fallback/recovery transitions once per state change. - User session selections are exact.
/model, the model picker,session_status(model=...), andsessions.patchstoremodelOverrideSource: "user"; if that selected provider/model is unreachable, OpenClaw fails visibly instead of falling through to another configured model. - Changing
agents.defaults.model.primarydoes not rewrite existing session selections. If status saysThis session is pinned to X; config primary Y will apply to new/unpinned sessions., switch the current session with/model Yor clear stale session state with/reset. - Cron
--model/ payloadmodelis a per-job primary. It still uses configured fallbacks unless the job supplies explicit payloadfallbacks(usefallbacks: []for a strict cron run). - CLI default-model and allowlist pickers respect
models.mode: "replace"by listing explicitmodels.providers.*.modelsinstead of loading the full built-in catalog. - The Control UI model picker asks the Gateway for its configured model view:
agents.defaults.modelswhen present, including provider-wideprovider/*entries, otherwise explicitmodels.providers.*.modelsplus providers with usable auth. The full built-in catalog is reserved for explicit browse views such asmodels.listwithview: "all"oropenclaw models list --all.
Quick model policy
- Set your primary to the strongest latest-generation model available to you.
- Use fallbacks for cost/latency-sensitive tasks and lower-stakes chat.
- For tool-enabled agents or untrusted inputs, avoid older/weaker model tiers.
Onboarding (recommended)
If you don't want to hand-edit config, run onboarding:
openclaw onboard
It can set up model + auth for common providers, including OpenAI Code (Codex) subscription (OAuth) and Anthropic (API key or Claude CLI).
Config keys (overview)
agents.defaults.model.primaryandagents.defaults.model.fallbacksagents.defaults.imageModel.primaryandagents.defaults.imageModel.fallbacksagents.defaults.pdfModel.primaryandagents.defaults.pdfModel.fallbacksagents.defaults.imageGenerationModel.primaryandagents.defaults.imageGenerationModel.fallbacksagents.defaults.videoGenerationModel.primaryandagents.defaults.videoGenerationModel.fallbacksagents.defaults.models(allowlist + aliases + provider params +provider/*dynamic provider entries)models.providers(custom providers written intomodels.json)
Provider configuration examples (including OpenCode) live in OpenCode.
Safe allowlist edits
Use additive writes when updating agents.defaults.models by hand:
openclaw config set agents.defaults.models '{"openai/gpt-5.4":{}}' --strict-json --merge
Interactive provider setup and `openclaw configure --section model` also merge provider-scoped selections into the existing allowlist, so adding Codex, Ollama, or another provider does not drop unrelated model entries. Configure preserves an existing `agents.defaults.model.primary` when provider auth is re-applied. Explicit default-setting commands such as `openclaw models auth login --provider <id> --set-default` and `openclaw models set <model>` still replace `agents.defaults.model.primary`.
"Model is not allowed" (and why replies stop)
If agents.defaults.models is set, it becomes the allowlist for /model and for session overrides. When a user selects a model that isn't in that allowlist, OpenClaw returns:
Model "provider/model" is not allowed. Use /models to list providers, or /models <provider> to list models.
Add it with: openclaw config set agents.defaults.models '{"provider/model":{}}' --strict-json --merge
- Add the model to
agents.defaults.models, or - Clear the allowlist (remove
agents.defaults.models), or - Pick a model from
/model list.
When the rejected command included a runtime override such as /model openai/gpt-5.5 --runtime codex, fix the allowlist first, then retry the same /model ... --runtime ... command. For native Codex execution, the selected model is still openai/gpt-5.5; the codex runtime selects the harness and uses Codex auth separately.
For local/GGUF models, store the full provider-prefixed ref in the allowlist,
for example ollama/gemma4:26b, lmstudio/Gemma4-26b-a4-it-gguf, or the
exact provider/model shown by openclaw models list --provider <provider>.
Bare local filenames or display names are not enough when the allowlist is
active.
If you want to limit providers without manually listing every model, add
provider/* entries to agents.defaults.models:
{
agents: {
defaults: {
models: {
"openai-codex/*": {},
"vllm/*": {},
},
},
},
}
With that policy, /model, /models, and model pickers show the discovered
catalog for those providers only. New models from the selected providers can
appear without editing the allowlist. Exact provider/model entries can be mixed
with provider/* entries when you need one specific model from another provider.
Example allowlist config:
{
agents: {
defaults: {
model: { primary: "anthropic/claude-sonnet-4-6" },
models: {
"anthropic/claude-sonnet-4-6": { alias: "Sonnet" },
"anthropic/claude-opus-4-6": { alias: "Opus" },
},
},
},
}
Switching models in chat (/model)
You can switch models for the current session without restarting:
/model
/model list
/model 3
/model openai/gpt-5.4
/model status
Full command behavior/config: Slash commands.
CLI commands
openclaw models list
openclaw models status
openclaw models set <provider/model>
openclaw models set-image <provider/model>
openclaw models aliases list
openclaw models aliases add <alias> <provider/model>
openclaw models aliases remove <alias>
openclaw models fallbacks list
openclaw models fallbacks add <provider/model>
openclaw models fallbacks remove <provider/model>
openclaw models fallbacks clear
openclaw models image-fallbacks list
openclaw models image-fallbacks add <provider/model>
openclaw models image-fallbacks remove <provider/model>
openclaw models image-fallbacks clear
openclaw models (no subcommand) is a shortcut for models status.
models list
Shows configured/auth-available models by default. Useful flags:
Full catalog. Includes bundled provider-owned static catalog rows before auth is configured, so discovery-only views can show models that are unavailable until you add matching provider credentials. Local providers only. Filter by provider id, for example `moonshot`. Display labels from interactive pickers are not accepted. One model per line. Machine-readable output.models status
Shows the resolved primary model, fallbacks, image model, and an auth overview of configured providers. It also surfaces OAuth expiry status for profiles found in the auth store (warns within 24h by default). --plain prints only the resolved primary model.
Example (Claude CLI):
claude auth login
openclaw models status
Scanning (OpenRouter free models)
openclaw models scan inspects OpenRouter's free model catalog and can optionally probe models for tool and image support.
Scan results are ranked by:
- Image support
- Tool latency
- Context size
- Parameter count
Input:
- OpenRouter
/modelslist (filter:free) - Live probes require OpenRouter API key from auth profiles or
OPENROUTER_API_KEY(see Environment variables) - Optional filters:
--max-age-days,--min-params,--provider,--max-candidates - Request/probe controls:
--timeout,--concurrency
When live probes run in a TTY, you can select fallbacks interactively. In non-interactive mode, pass --yes to accept defaults. Metadata-only results are informational; --set-default and --set-image require live probes so OpenClaw does not configure an unusable keyless OpenRouter model.
Models registry (models.json)
Custom providers in models.providers are written into models.json under the agent directory (default ~/.openclaw/agents/<agentId>/agent/models.json). This file is merged by default unless models.mode is set to replace.
- Non-empty `baseUrl` already present in the agent `models.json` wins.
- Non-empty `apiKey` in the agent `models.json` wins only when that provider is not SecretRef-managed in current config/auth-profile context.
- SecretRef-managed provider `apiKey` values are refreshed from source markers (`ENV_VAR_NAME` for env refs, `secretref-managed` for file/exec refs) instead of persisting resolved secrets.
- SecretRef-managed provider header values are refreshed from source markers (`secretref-env:ENV_VAR_NAME` for env refs, `secretref-managed` for file/exec refs).
- Empty or missing agent `apiKey`/`baseUrl` fall back to config `models.providers`.
- Other provider fields are refreshed from config and normalized catalog data.
Marker persistence is source-authoritative: OpenClaw writes markers from the active source config snapshot (pre-resolution), not from resolved runtime secret values. This applies whenever OpenClaw regenerates `models.json`, including command-driven paths like `openclaw agent`.
Related
- Agent runtimes — OpenClaw, Codex, and other agent loop runtimes
- Configuration reference — model config keys
- Image generation — image model configuration
- Model failover — fallback chains
- Model providers — provider routing and auth
- Music generation — music model configuration
- Video generation — video model configuration