Skip to content

feat(onboarding): adopt the provider's recommended model on first key placement (draft)#75

Merged
LightDriverCS merged 4 commits into
mainfrom
aurelius/fresh-key-default-model
Jun 23, 2026
Merged

feat(onboarding): adopt the provider's recommended model on first key placement (draft)#75
LightDriverCS merged 4 commits into
mainfrom
aurelius/fresh-key-default-model

Conversation

@LightDriverCS

Copy link
Copy Markdown

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 hits reason=auth on the first turn (no openai key) and had to hand-set agents.defaults.model. Now key placement adopts the keyed provider's recommended model when no default is configured — mirroring the existing gateway install auto-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.tsRECOMMENDED_MODEL_BY_PROVIDER + resolveRecommendedModelForProvider (alongside DEFAULT_PROVIDER/DEFAULT_MODEL; one place to bump).
  • src/commands/models/auth.tsadoptProviderDefaultModelIfUnset, called after paste-api-key and paste-token persist the profile.
  • src/agents/defaults.test.ts — new (5 cases).

Behavior + guardrails

  • Runs only at key placement, only when agents.defaults.model is unset → never overrides an operator's choice.
  • No-op when the provider has no recommended model, or when the model is absent from a non-empty catalog (stale-registry protection). An empty catalog (fresh box, discovery not yet run) is treated as "can't disprove" — the authored registry value is adopted.
  • Logs what it set + how to change it. Reuses applyDefaultModelPrimaryUpdate (the same writer /model uses).

Firebase / deploy impact

None — CLI-only.

Local gates

  • vitest run src/agents/defaults.test.ts5/5 (10/10 with the co-run file)
  • ✅ existing models/auth suite — 4/4 (paste commands unaffected)
  • tsc --noEmit — clean on touched files
  • oxlint — clean

Notes / follow-ups

🤖 Generated with Claude Code

Agent-Aurelius and others added 2 commits June 17, 2026 16:13
… 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]>
@LightDriverCS
LightDriverCS marked this pull request as ready for review June 17, 2026 22:49

@Agent-Aurelius Agent-Aurelius left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anvil auto-approval — verdict READY, non-code-owned. Approved under the dedicated Anvil reviewer identity.

@github-actions

Copy link
Copy Markdown

Dependency Guard

This PR changes dependency-related files. Maintainers should confirm these changes are intentional.

Changed files:

  • extensions/acpx/npm-shrinkwrap.json

Maintainer follow-up:

  • Review whether the dependency changes are intentional.
  • Inspect resolved package deltas when lockfile, shrinkwrap, or workspace dependency policy changes are present.
  • Treat package-lock.json and npm-shrinkwrap.json diffs as security-review surfaces.
  • Run pnpm deps:changes:report -- --base-ref origin/main --markdown /tmp/dependency-changes.md --json /tmp/dependency-changes.json locally for detailed release-style evidence.

@github-actions

Copy link
Copy Markdown

Dependency graph changes noted

This PR includes dependency graph changes. The dependency guard is informational because the PR author is a repository admin or a member of @openclaw/openclaw-secops.

  • Current SHA: 919fd578f58360e81a62c3f7a35a63ac43544a67
  • Trusted actor: @LightDriverCS
  • Trusted role: pull request author; repository admin

Security review is still recommended before merge when the dependency graph change is intentional.

@LightDriverCS

Copy link
Copy Markdown
Author

Anvil update: pushed 919fd57 to refresh extensions/acpx/npm-shrinkwrap.json after the CI shrinkwrap guard failed on registry deprecation metadata for @zed-industries/codex-acp packages.

Local verification after the fix:

  • pnpm test src/commands/models/auth.test.ts extensions/anthropic/index.test.ts
  • pnpm deps:shrinkwrap:check
  • pnpm check
  • pnpm build

The new GitHub CI run for 919fd57 is in progress: https://github.com/BenchAGI/openclaw/actions/runs/28052361837

@LightDriverCS
LightDriverCS merged commit b251d37 into main Jun 23, 2026
153 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants