feat(onboarding): adopt the provider's recommended model on first key placement (draft)#75
Conversation
… placement Gap 4 from the local-model bring-up: a fresh install defaults the agent model to the global baseline openai/gpt-5.5. When the only key placed is Anthropic's, the first turn fails with `reason=auth` (no openai key) — operators had to hand-set `agents.defaults.model` to recover. Now, when an operator places their first key via `models auth paste-api-key` / `paste-token` and `agents.defaults.model` is NOT configured, OpenClaw adopts that provider's recommended model (mirrors the existing `gateway install` auto-default pattern): - Authoritative source: RECOMMENDED_MODEL_BY_PROVIDER in agents/defaults.ts, alongside the existing DEFAULT_PROVIDER/DEFAULT_MODEL baseline (one place to bump per provider). NOT a guess at array ordering — provider model lists are alphabetically sorted, so "first model" is not canonical. - Safety: the chosen model is validated against the live model catalog before persisting, so a stale registry entry can never write a model id that no longer exists. No-op when a default is already set (never overrides the operator), the provider has no recommended model, or the model isn't in a non-empty catalog. An authored value is adopted only when nothing disproves it. Tests: defaults.test.ts (5 cases — baseline/anthropic/case-insensitive/unknown/ normalized keys). tsc clean; oxlint clean; existing models/auth suite 4/4. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Agent-Aurelius
left a comment
There was a problem hiding this comment.
Anvil auto-approval — verdict READY, non-code-owned. Approved under the dedicated Anvil reviewer identity.
Dependency GuardThis PR changes dependency-related files. Maintainers should confirm these changes are intentional. Changed files:
Maintainer follow-up:
|
Dependency graph changes notedThis PR includes dependency graph changes. The dependency guard is informational because the PR author is a repository admin or a member of
Security review is still recommended before merge when the dependency graph change is intentional. |
|
Anvil update: pushed Local verification after the fix:
The new GitHub CI run for |
Scope
Closes the last fresh-install onboarding gap from the local-model bring-up. A fresh install defaults the agent model to the global baseline
openai/gpt-5.5; a customer who places only an Anthropic key then hitsreason=authon the first turn (no openai key) and had to hand-setagents.defaults.model. Now key placement adopts the keyed provider's recommended model when no default is configured — mirroring the existinggateway installauto-default pattern.Why this shape (not a guess)
There is no authoritative per-provider default in the codebase today — the wizard resolves it interactively, and provider model lists are alphabetically sorted (so "first model" is not canonical). Rather than guess, this adds an explicit, maintained registry next to the existing baseline, and validates the chosen model against the live catalog before persisting so a stale entry can never write a bogus id.
Touched surfaces
src/agents/defaults.ts—RECOMMENDED_MODEL_BY_PROVIDER+resolveRecommendedModelForProvider(alongside DEFAULT_PROVIDER/DEFAULT_MODEL; one place to bump).src/commands/models/auth.ts—adoptProviderDefaultModelIfUnset, called afterpaste-api-keyandpaste-tokenpersist the profile.src/agents/defaults.test.ts— new (5 cases).Behavior + guardrails
agents.defaults.modelis unset → never overrides an operator's choice.applyDefaultModelPrimaryUpdate(the same writer/modeluses).Firebase / deploy impact
None — CLI-only.
Local gates
vitest run src/agents/defaults.test.ts— 5/5 (10/10 with the co-run file)models/authsuite — 4/4 (paste commands unaffected)tsc --noEmit— clean on touched filesoxlint— cleanNotes / follow-ups
DEFAULT_MODEL.🤖 Generated with Claude Code