Skip to content

refactor(models): prepare selection policy once - #130413

Merged
steipete merged 2 commits into
mainfrom
codex/model-policy-preparation-cleanup
Aug 26, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/model-policy-preparation-cleanup

Conversation

@steipete

@steipete steipete commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Model selection and catalog visibility repeatedly prepare the same model policy, aliases, and catalog metadata. They also compute and forward an automatic-fallback set that no production code reads. This makes model handling harder to maintain and keeps redundant work in status, selection, and reset paths.

Why This Change Was Made

Use one private preparation path and keep explicit selection authorization separate from automatic failover. Delete the unused fallback set, its reset-command resolver, forwarding wrappers, and the duplicate primary-model string normalizer. The existing fallback execution owner and catalog-retention path remain unchanged.

Policy aliases retain their policy owner's scope; selection/display aliases retain the selected agent's scope. Exact visibility refs are resolved once. Existing callable names remain exported, and the public allowed-set result retains the three fields published in v2026.7.1-2. The removed fallback property is absent throughout that stable tag and has no production readers on current main.

Production: +91/-287 (net -196). Tests/support: +4/-12 (net -8). One assertion-count baseline entry is reduced to match the deleted assertion; no new config, auth, persistence, SDK entrypoint, or default surface.

User Impact

No intended behavior change. Model selection, inherited allowlists, per-agent aliases, configured fallback execution, and reset behavior keep their existing contracts with less duplicate code.

Release context: internal model-policy cleanup following #130381; no operator action required.

Evidence

  • Before-edit baseline: 191 selection/resolve/visibility/manifest-workspace/reset/directive tests passed.
  • Rebuilt isolated CLI models status --json --agent worker matches its before-edit baseline: agent alias approved -> lab/agent, inherited allowed refs lab/allowed and lab/primary, automatic fallback lab/fallback retained but excluded from explicit selection.
  • Independent Codex autoreview: no actionable findings.
  • All 415 tests across 12 selection, manifest, visibility, plugin-runtime, reset, directive, fallback, cron, and CLI-status files passed.
  • Changed-file checks passed ratchets, format, boundaries, dead-export scans, and production/test types. Import-order lint and return consistency are corrected, targeted lint passes, and 153 selection/visibility tests pass again. All remaining selected guards passed, including script lint, database-first, runtime sidecar, import cycles, webhook and pairing checks. These were completed across the original runs plus targeted correction/remaining-guard runs, not one uninterrupted full run.
  • Fresh Codex review of the lint correction has no actionable findings. Exact-head CI run 33015565242 passed on 57cbb38e9dca602f7583498bb0afeaf55674a6e0; the prior run failed lint.

Focused test command:

node scripts/run-vitest.mjs src/agents/model-selection.test.ts src/agents/model-selection-resolve.test.ts src/agents/model-visibility-policy.test.ts src/agents/model-selection-manifest-workspace.test.ts src/auto-reply/reply/session-reset-model.test.ts src/auto-reply/reply/model-selection-directive.test.ts src/agents/model-selection.plugin-runtime.test.ts src/agents/model-catalog-visibility.test.ts src/agents/model-fallback.test.ts src/cron/isolated-agent/run.cron-model-override.test.ts src/cron/isolated-agent/run.model-policy-config-preserved.test.ts src/commands/models/list.status.test.ts
node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/agents/model-selection-shared.ts src/agents/model-selection.ts

No provider request transport or live Gateway configuration changed. The CLI proof uses only synthetic configuration and isolated state.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 26, 2026
@steipete steipete self-assigned this Aug 26, 2026
@steipete
steipete merged commit 9afd058 into main Aug 26, 2026
214 checks passed
@steipete
steipete deleted the codex/model-policy-preparation-cleanup branch August 26, 2026 22:00
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 26, 2026
* origin/main: (275 commits)
  fix(ai): require explicit compatible-provider endpoints (#130453)
  test(control-ui): guard the hand-mirrored theme --bg copies (#130444)
  fix(onboard): preserve the saved skills package manager (#130438)
  improve(worker): diagnose admission-deadline failures and widen daemon revalidation budget (#130435)
  fix(plugins): align diffs external install metadata (#130362)
  refactor(models): consolidate config normalization (#130439)
  fix(browser): accept common keyboard aliases (#130401)
  fix(release): refresh IMAP plugin baselines (#130351)
  fix(tests): type sticky model agent fixtures (#130441)
  fix(qa): track current Slack progress cards (#130354)
  feat(ui): refine the mobile composer (#130308)
  fix(ui): clarify gateway disconnect status in tab title (#130364)
  test(qa): await gateway startup before network probes (#130353)
  fix(qa): run Buzz profile scenarios with pooled credentials (#130316)
  fix(crabbox): keep the setup failure reason and name its phase (#130425)
  fix: dashboard tools target the wrong Gateway after admission (#130112)
  fix(ui): distinguish inherited model defaults from session pins (#120805)
  feat(feishu): let agents resend received stickers (#130374)
  refactor(models): prepare selection policy once (#130413)
  fix(ui): make dashboard side panels enter split view (#130426)
  ...

# Conflicts:
#	test/scripts/docker-build-helper.test.ts
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
* refactor(models): prepare selection policy once

* style(models): fix selection exports and return consistency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant