Skip to content

fix: use numeric sort for model alias resolution - #96640

Closed
mralonsocorona wants to merge 1 commit into
openclaw:mainfrom
mralonsocorona:fix/model-resolver-numeric-sort-96588
Closed

mralonsocorona wants to merge 1 commit into
openclaw:mainfrom
mralonsocorona:fix/model-resolver-numeric-sort-96588

Conversation

@mralonsocorona

@mralonsocorona mralonsocorona commented Jun 25, 2026 •

Copy link
Copy Markdown

What Problem This Solves

Fixes alias model resolution for version-like model ids that cross into double-digit minor versions.

Previously, tryMatchModel sorted candidate model ids with plain lexicographic localeCompare, so ids like claude-opus-4-9 could sort above claude-opus-4-10. This caused partial aliases such as opus to resolve to an older model.

This PR updates model candidate sorting to use numeric-aware collation and adds a regression test for the 4-9 vs 4-10 case.

Fixes #96588.

Evidence

  • node scripts/run-vitest.mjs run src/agents/sessions/model-resolver.test.ts → Test Files 1 passed, Tests 3 passed
  • pnpm exec oxfmt --check --threads=1 src/agents/sessions/model-resolver.ts src/agents/sessions/model-resolver.test.ts → All matched files use the correct format
  • Observed behavior: parseModelPattern("opus", ...) selects claude-opus-4-10 over claude-opus-4-9 after the numeric-aware sort fix

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. size: XS labels Jun 25, 2026
@clawsweeper

clawsweeper Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

Current main already contains the same central fix, with slightly stronger regression coverage, via merged pull request #96609. The latest release still has the old comparator, so this is fixed on main only and this conflicting branch is no longer needed as a landing candidate.

Root-cause cluster
Relationship: superseded
Canonical: #96609
Summary: This PR targets the same model alias numeric-ordering bug as the merged canonical pull request, and current main already contains the canonical implementation and test.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review details

Best possible solution:

Keep the merged current-main implementation from #96609 and close this conflicting duplicate branch rather than trying to land it separately.

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

No as a current-main failure: source inspection shows current main now uses numeric-aware sorting and includes a regression test for the double-digit alias rollover. The pre-fix bug is documented by the linked issue and the merged canonical fix.

Is this the best way to solve the issue?

Yes. Numeric-aware sorting at the existing tryMatchModel sort points is the narrowest maintainable fix, and current main already has that implementation with stronger coverage than this branch.

Security review:

Security review cleared: The PR diff only changes local TypeScript model-id sorting logic and a colocated test, with no dependency, lockfile, CI, secret, publishing, or external code execution surface changes.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • zw-xysk: Authored the merged current-main fix commit that changed the exact comparator lines and added the model resolver regression test. (role: merged canonical fix author; confidence: high; commits: 7ae52dc56ecf; files: src/agents/sessions/model-resolver.ts, src/agents/sessions/model-resolver.test.ts)
  • steipete: Recent main file history shows adjacent agent/runtime work touching or carrying this resolver surface during the reusable AI runtime extraction and agent runtime refactor. (role: recent adjacent area contributor; confidence: medium; commits: 062f88e3e3af, bb46b79d3c14; files: src/agents/sessions/model-resolver.ts)

Codex review notes: model internal, reasoning high; reviewed against b95b9e448794; fix evidence: commit 7ae52dc56ecf, main fix timestamp 2026-06-29T01:55:25Z.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Jun 25, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 25, 2026
@mralonsocorona

Copy link
Copy Markdown
Author

The PR evidence has been updated and the Real behavior proof check is now passing.

Current status from gh pr checks:

  • 0 failing
  • 64 successful
  • 0 pending
  • Real behavior proof: pass

The PR is also currently:

  • mergeStateStatus: CLEAN
  • mergeable: MERGEABLE

It looks like the old status: 📣 needs proof label is still present from the earlier failed proof run. Could a maintainer or bot refresh/remove that label when convenient?

Thanks.

@clawsweeper

clawsweeper Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

@mralonsocorona thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward.

Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive.

Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it.

@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Jul 7, 2026
@clawsweeper

clawsweeper Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jul 7, 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 P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

model resolution: alias selects older version via lexicographic ordering once a family reaches double-digit minor versions

1 participant