Skip to content

refactor(models): consolidate config normalization - #130439

Merged
steipete merged 1 commit into
mainfrom
codex/model-config-normalization-cleanup
Aug 26, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/model-config-normalization-cleanup

Conversation

@steipete

@steipete steipete commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Model config edits and runtime defaults each implement the same primary/fallback normalization. Provider catalog materialization also repeats change tracking around every normalization stage, while merge/default code duplicates the shared positive-number contract.

Why This Change Was Made

Move model-value normalization to the existing config input owner and use it from both callers. Keep their different field traversals unchanged. Use returned object identity for provider change tracking, and reuse the existing positive-finite-number helper for sizing values. Consolidate default-row change detection without changing authored-field precedence.

Production: +93/-196 (net -103). Tests: +17/-2 (net +15). The assertion baseline shrinks by one deleted assertion. No dependencies, config keys, defaults, migration, persistence format, or public SDK entrypoints are added or removed.

User Impact

No intended behavior change. Existing Google/Together ref canonicalization, fallback order, custom fields, duplicate-row precedence, partial-cost completion, provider key collisions and credential-marker handling remain intact. Authored capabilities and sizing still win; frozen catalog metadata is still cloned before defaulting.

Release context: internal model-config cleanup following the catalog/policy simplifications in #130381 and #130413. No operator action required.

Evidence

  • Before-edit baseline: 63 model-alias/default, merge, provider-normalization and explicit-reasoning tests pass.
  • After-edit: 313 tests across seven default/config, provider merge/normalization, gateway config and CLI config files pass.
  • Extend the existing deduplication test through repeated normalization/publication, proving unchanged object identity and retained credential-marker ownership even on a no-op pass. Existing partial-cost composition coverage remains.
  • Targeted lint and formatting pass. Independent Codex autoreview reports no actionable findings.
  • Full build/postbuild passes. Rebuilt isolated CLI config get agents.defaults.model --json matches its before-edit baseline. A real primary-model write/readback persists the canonical target, preserves untouched fallback source text, and materializes canonical ordered fallbacks on read. Initial probes correctly returned No change for an equivalent value and rejected unknown models; the write probe then used explicit local catalog rows with plugins disabled.
  • Full changed-file gate passed, including both typechecking lanes, lint, formatting, assertion/dead-code/coercion ratchets, provider boundaries, database/sidecar/import-cycle guards and webhook/pairing guards.
  • Exact-head CI run 33017313714 completed successfully on 3a830ccb3ca02264c142c05762359027094868c8.
  • ClawSweeper review found no actionable correctness/security issues. Its remaining merge-risk/rank-up request—to finish exact-head checks before landing—is now satisfied.

Focused proof commands:

node scripts/run-vitest.mjs src/config/model-alias-defaults.test.ts src/config/defaults.test.ts src/agents/models-config.merge.test.ts src/agents/models-config.providers.normalize-keys.test.ts src/agents/models-config.preserves-explicit-reasoning-override.test.ts src/gateway/server-methods/config.test.ts src/cli/config-cli.test.ts
node scripts/check-changed.mjs -- src/config/defaults.ts src/config/model-input.ts src/config/model-input-normalization.ts src/agents/models-config.merge.ts src/agents/models-config.providers.normalize.ts src/agents/models-config.providers.normalize-keys.test.ts config/assertion-safety-baseline.txt

No provider request transport or live Gateway is modified. Operator proof uses synthetic configuration and isolated state. The storage writer is unchanged; only the preparation flow is simplified.

Follow-up candidate: consolidate remaining MiniMax/provider-manifest model builders in a separate change. Any provider capability restoration needs its own authenticated provider proof.

Post-merge combined proof on main 39454997b4497b861bd2fa2fe412434b8282c188: fresh full build/postbuild and 218 tests across six catalog/selection/config files passed. Rebuilt CLI config and per-agent policy outputs match their saved baselines. models list --all --provider zai --json still reports zai/glm-5.3-flash with text+image input, context window 1048576 and missing=false. All smoke state was isolated; no live Gateway or provider credential changes.

@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 agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 26, 2026
@steipete
steipete marked this pull request as ready for review August 26, 2026 21:52
@steipete steipete self-assigned this Aug 26, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 5:58 PM ET / 21:58 UTC.

ClawSweeper review

What this changes

The branch moves existing model-selection and provider-catalog normalization into shared config helpers while preserving canonical references, defaulting, and secret-marker handling.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

No blocking correctness finding was identified. This maintainer-owned refactor is not implemented on current main and should remain open for its exact-head checks to finish.

Priority: P3
Reviewed head: 3a830ccb3ca02264c142c05762359027094868c8

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused refactor has a coherent owner boundary and behavior-preservation coverage, with final exact-head validation still pending.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored internal refactor is exempt from the external-contributor real-behavior-proof gate; its PR body nevertheless records isolated CLI write/readback evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored internal refactor is exempt from the external-contributor real-behavior-proof gate; its PR body nevertheless records isolated CLI write/readback evidence.
Evidence reviewed 8 items Shared selection owner: The added shared helper canonicalizes string, primary, and fallback model references while retaining the original object when no value changes.
Mutation callers: Both CLI mutation preparation and Gateway submitted-config validation call the common normalization boundary before validation and persistence.
Defaulting and behavioral coverage: Agent defaults reuse the helper for default and listed-agent selections; existing tests cover retired Gemini/Together primary and fallback references plus per-agent normalization.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

$ node scripts/run-node.mjs --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 103.13 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 14.1s
[plugin-control-plane-loads] verified 36 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4242ms (slowest: built plugin control-plane loads 3510ms)

OpenClaw 2026.8.1 (3a830cc) — All your chats, one OpenClaw.

Usage: openclaw [options] [command]

Options:
  --container ‹name›   Run the CLI inside a running Podman/Docker container named ‹name› (default: env OPENCLAW_CONTAINER)
  --dev                Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)
  -h, --help           Display help for command
  --log-level ‹level›  Global log level override for file + console (silent|fatal|error|warn|info|debug|trace)
  --no-color           Disable ANSI colors
  --profile ‹name›     Use a named profile (iso
… output truncated …

Assertions:

  • PASS expect_output: Usage:

How this fits together

CLI and Gateway config writes normalize model references before validation and persistence, while provider catalogs are normalized before model defaults and agent selection consume them. The change consolidates those preparation steps without adding a new user-facing configuration surface.

flowchart LR
  A[CLI and Gateway config writes] --> B[Model reference normalization]
  C[Provider catalog rows] --> D[Provider catalog normalization]
  B --> E[Canonical config and defaults]
  D --> E
  E --> F[Agent model selection]
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head checks are still queued or running, so landing should wait for the final branch validation rather than relying only on the refactor's stated local evidence.
Agent review details

Security

None.

PR surface

Source -103, Tests +15, Other 0. Total -88 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 5 93 196 -103
Tests 1 17 2 +15
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 7 111 199 -88

Review metrics

Metric Value Why it matters
Production vs test LOC production -103, tests +15, baseline 0 net The refactor removes duplicated runtime logic while adding focused preservation coverage.
Configuration contract 0 keys, defaults, migrations, or SDK entrypoints added or removed The change affects normalization internals without expanding the operator configuration surface.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep one canonical model-selection normalizer at the config-input owner and one identity-based provider normalization flow, then land after exact-head validation confirms preserved config behavior.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep one canonical model-selection normalizer at the config-input owner and one identity-based provider normalization flow, then land after exact-head validation confirms preserved config behavior.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this is a refactor, and the relevant evidence is preservation of existing config normalization behavior rather than reproduction of a defect.

Is this the best way to solve the issue?

Yes. Moving the duplicate selection logic to the existing config-input owner lets CLI mutation, Gateway validation, and runtime defaults use one canonical implementation without adding a parallel path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 99a2434f7b89.

Labels

Label changes:

  • add P3: This is a behavior-preserving internal model-config cleanup with no reported user-facing regression.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored internal refactor is exempt from the external-contributor real-behavior-proof gate; its PR body nevertheless records isolated CLI write/readback evidence.

Label justifications:

  • P3: This is a behavior-preserving internal model-config cleanup with no reported user-facing regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored internal refactor is exempt from the external-contributor real-behavior-proof gate; its PR body nevertheless records isolated CLI write/readback evidence.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame covers the central model-reference and defaults surfaces, and the same contributor authored the adjacent merged catalog-normalization work. (role: recent model configuration and catalog-normalization contributor; confidence: high; commits: d9b41332e458, cf457d0199fa; files: src/config/model-input.ts, src/config/defaults.ts, src/agents/models-config.merge.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let the queued exact-head checks complete before landing.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit a0791fd into main Aug 26, 2026
288 checks passed
@steipete
steipete deleted the codex/model-config-normalization-cleanup branch August 26, 2026 22:14
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant