Skip to content

fix(agents): preserve exact model matches in session SDK - #139900

Merged
steipete merged 2 commits into
mainfrom
codex/130706-session-model-matching-20260905
Sep 6, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/130706-session-model-matching-20260905

Conversation

@steipete

@steipete steipete commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Session SDK selection could choose Alpha when the caller requested the distinct model alpha, or silently choose a provider for an ambiguous reference. Duplicate catalog rows could also change the selected metadata.

Why This Change Was Made

Share exact-first provider and model matching across SDK and CLI selection. Compare complete provider/model identities, including slash-containing components, before tolerant or fuzzy lookup. Preserve registry-first metadata when duplicate rows or alternate names identify the same model. Ambiguity produces an actionable error.

The same flow preserves explicit providers, raw IDs, human names, alias/date and numeric ordering, literal colons, thinking suffixes, custom IDs, and case-insensitive glob scopes. It removes the overwritten provider map and duplicate suffix, ordering, and fallback branches.

User Impact

Selections retain the requested model identity and metadata. References that identify several models require an exact provider/model choice. This focused repair was found while extracting #130706; it adds no public argument or configuration option.

Evidence

  • All 55 owner tests and typed lint pass; regressions were reproduced before repair.
  • Real resource loader → jiti extension SDK → model registry first-load and explicit-reload proof passes on tree b461b36233f81a0b86c9320cd2d6aee839c05ca4, committed as c49515c69621af70e744100c2f4331b119b8a666. The matrix includes exact/folded identities, duplicate metadata and names, every registered provider split, ambiguity, raw IDs, fuzzy/version ordering, literal colon IDs, thinking suffixes, custom models and globs. Proof uses isolated HOME/state/config and an allowlisted environment.
  • Independent P2 review is scoped-clean on that exact source.
  • Production: +7 lines (217 added / 210 removed); tests: +333; docs: +7. Remaining growth preserves distinct identity and parsing contracts within one shared matcher.

The exact committed head passed the complete build (455 seconds), full changed gate, and compiled SDK first-load/reload replay. All 8,547 runtime files remained unchanged during replay (manifest SHA256 57430d4cc6bc3b387d65db7c5577088ff7cade2adc80bfef0d7a9d936f699d4b). Exact-head CI passed.

Maintainer disposition: accept the documented ambiguity diagnostic as the repair for arbitrary wrong-model selection. Callers can use exact identities or specify the provider separately; public function signatures and unambiguous fuzzy/custom selection remain supported.

Resolve model references through one collector that prefers exact model IDs
before unambiguous case-insensitive matches. Stop ambiguous references before
fuzzy selection or custom-model construction instead of choosing the first
provider or a differently cased model.

Preserve qualified-provider precedence, raw slash IDs, human names, version
ordering, thinking suffixes, custom models and glob scopes. Remove duplicate
folded lookup branches and document the session SDK contract.

Refs #130706. Production code decreases by 28 lines.
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Sep 6, 2026
@steipete
steipete marked this pull request as ready for review September 6, 2026 07:36
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 6, 2026, 5:22 AM ET / 09:22 UTC.

ClawSweeper review

What this changes

The session SDK now prefers exact provider/model identities, preserves first-row catalog metadata, and reports ambiguous selections while retaining supported fuzzy matching and fallbacks.

Merge readiness

⛔ Blocked before merge - 1 item remains

This focused repair remains necessary: current main and the latest release retain the old matching behavior. No blocking introduced defect was found; the maintainer-authored PR explicitly documents its compatibility change.

Priority: P2
Reviewed head: c49515c69621af70e744100c2f4331b119b8a666

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, well-covered identity repair with no blocking finding and a clearly disclosed compatibility change.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor proof gate does not apply to this MEMBER-authored PR. The captured body reports isolated first-load/reload proof through the real resource loader and jiti SDK into the changed resolver; the underlying execution transcript was not supplied.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor proof gate does not apply to this MEMBER-authored PR. The captured body reports isolated first-load/reload proof through the real resource loader and jiti SDK into the changed resolver; the underlying execution transcript was not supplied.
Evidence reviewed 10 items Introduced implementation: The verified merge-base-to-head diff shares exact-first matching, rejects ambiguous identities before fuzzy/custom fallback, and preserves existing public function signatures.
Current main still needs the repair: Current main lowercases identities before selecting matches, uses an overwritten case-folded provider map, and permits ambiguous exact lookup to reach fuzzy selection.
Latest-release comparison: The resolver in v2026.9.2 has blob 4237d950697eac2c793dcfda1faf6addf3baad4a, identical to the inspected current-main resolver; this release does not contain the proposed repair.
Findings None None.
Security None None.

How this fits together

Session extensions use OpenClaw’s model-selection helpers to turn model references and registry entries into a selected model and optional thinking level. That selection feeds agent-session initialization.

flowchart TD
  A[Session extension reference] --> C[Model selection helpers]
  B[Model registry] --> C
  C --> D{Exact or unambiguous match}
  D -->|Yes| E[Selected model and thinking level]
  D -->|Ambiguous| F[Actionable diagnostic]
  D -->|No match| G[Supported fuzzy or custom fallback]
  G --> E
Loading

Before merge

  • Resolve merge risk (P1) - Existing session extensions that relied on arbitrary selection for ambiguous bare or case-folded references will now receive diagnostics and must supply exact identities. This SDK compatibility change is explicitly acknowledged in the maintainer-authored body and documentation.
Agent review details

Security

None.

PR surface

Source +7, Tests +333, Docs +7. Total +347 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 217 210 +7
Tests 1 333 0 +333
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 557 210 +347

Review metrics

Metric Value Why it matters
Production versus regression coverage production +7 net lines; tests +333 lines The small production increase consolidates matching paths while the added tests protect distinct identity and parsing contracts.

Merge-risk options

Maintainer options:

  1. Accept the documented ambiguity contract (recommended)
    Retain the explicitly documented diagnostic behavior and exact-identity recovery path instead of preserving arbitrary model selection.

Technical review

Best possible solution:

Keep one exact-first resolver aligned with registry identity, with explicit diagnostics for ambiguity and preserved saved-session lookup and supported fallback behavior.

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

Yes, from source: current-main CLI selection takes the first case-folded bare-ID match, so a catalog containing Alpha before alpha can select Alpha when alpha was requested. No code or tests were executed during this read-only review.

Is this the best way to solve the issue?

Yes. Sharing exact-first matching follows the registry’s existing identity contract and prevents ambiguity from falling through to another selection path; the intentional SDK compatibility change is documented.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against cb22e0704114.

Labels

Label justifications:

  • P2: This repairs a bounded session SDK selection defect without evidence of a widespread urgent outage.
  • merge-risk: 🚨 compatibility: Ambiguous SDK references that previously selected a model can now require callers to provide an exact identity.
  • 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: The external-contributor proof gate does not apply to this MEMBER-authored PR. The captured body reports isolated first-load/reload proof through the real resource loader and jiti SDK into the changed resolver; the underlying execution transcript was not supplied.

Evidence

What I checked:

  • Introduced implementation: The verified merge-base-to-head diff shares exact-first matching, rejects ambiguous identities before fuzzy/custom fallback, and preserves existing public function signatures. (src/agents/sessions/model-resolver.ts:74, c49515c69621)
  • Current main still needs the repair: Current main lowercases identities before selecting matches, uses an overwritten case-folded provider map, and permits ambiguous exact lookup to reach fuzzy selection. (src/agents/sessions/model-resolver.ts:45, cb22e0704114)
  • Latest-release comparison: The resolver in v2026.9.2 has blob 4237d950697eac2c793dcfda1faf6addf3baad4a, identical to the inspected current-main resolver; this release does not contain the proposed repair. (src/agents/sessions/model-resolver.ts, 3928bad9badf)
  • Authoritative identity contract: The registry finds the first row using strict provider and model-ID equality; the shared AI identity helper likewise compares both components exactly. (src/agents/sessions/model-registry.ts:727, c49515c69621)
  • Session extension implementation boundary: The extension loader virtualizes the session SDK using OpenClaw’s extension-safe barrel, which exports this resolver. The changed behavior has no affirmative dependency on the Codex harness or protocol. (src/agents/sessions/extension-sdk.ts:17, c49515c69621)
  • Compatibility and recovery documentation: The SDK documentation explains exact-first matching, ambiguity diagnostics, separate provider selection for colliding combined references, and retained human-name, version, and glob matching. Public docs: docs/plugins/sdk-overview.md. (docs/plugins/sdk-overview.md:595, c49515c69621)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • zw-xysk: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-06T07:36:24.099Z sha 75ce736 :: blocked before merge. :: none
  • reviewed 2026-09-06T08:08:32.272Z sha 75ce736 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 Sep 6, 2026
Share registered-provider scope preparation across reference lookup and CLI
selection. Preserve full tuple spelling across slash boundaries, exact model
IDs, literal components and thinking suffixes. Ambiguous references must not
choose an owner through fuzzy ranking or custom-model fallback.

Keep all duplicate names as aliases while returning the registry-first model
object. Consolidate suffix, version ordering and fallback selection, removing
the overwritten provider map and first-slash inference path.

Check complete literal IDs before interpreting thinking suffixes; explicit
provider selection keeps its existing override.

All 55 owner tests and typed lint pass. The complete matching cut adds seven
production lines after removing duplicate paths. Refs #130706.
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Maintainer disposition: accepting the documented ambiguity contract. Choosing an arbitrary provider or case-distinct model is the defect this repairs; the diagnostic explains how to select the exact identity or supply the provider separately. Unambiguous fuzzy/custom matching and existing function signatures remain supported.

Validated final head c49515c69621af70e744100c2f4331b119b8a666: 55 focused tests, typed lint, independent P2 review, complete build, full changed gate, and real compiled resource-loader → jiti session SDK → model-registry first-load/reload proof all passed. The separate duplicate-registry probe passed 7/7 and retained the first row's exact object and metadata.

All 8,547 runtime files stayed unchanged during the compiled replay; manifest SHA256 57430d4cc6bc3b387d65db7c5577088ff7cade2adc80bfef0d7a9d936f699d4b. Exact-head CI is green. Production delta is +7, tests +333, docs +7. Previous-head proof remains historical.

@steipete
steipete merged commit 940597c into main Sep 6, 2026
184 of 186 checks passed
@steipete
steipete deleted the codex/130706-session-model-matching-20260905 branch September 6, 2026 09:36
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
…9900)

* fix(agents): preserve exact session model identities

Resolve model references through one collector that prefers exact model IDs
before unambiguous case-insensitive matches. Stop ambiguous references before
fuzzy selection or custom-model construction instead of choosing the first
provider or a differently cased model.

Preserve qualified-provider precedence, raw slash IDs, human names, version
ordering, thinking suffixes, custom models and glob scopes. Remove duplicate
folded lookup branches and document the session SDK contract.

Refs openclaw#130706. Production code decreases by 28 lines.

* fix(agents): preserve canonical session model references

Share registered-provider scope preparation across reference lookup and CLI
selection. Preserve full tuple spelling across slash boundaries, exact model
IDs, literal components and thinking suffixes. Ambiguous references must not
choose an owner through fuzzy ranking or custom-model fallback.

Keep all duplicate names as aliases while returning the registry-first model
object. Consolidate suffix, version ordering and fallback selection, removing
the overwritten provider map and first-slash inference path.

Check complete literal IDs before interpreting thinking suffixes; explicit
provider selection keeps its existing override.

All 55 owner tests and typed lint pass. The complete matching cut adds seven
production lines after removing duplicate paths. Refs openclaw#130706.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. 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