Repository navigation
fix(agents): preserve exact model matches in session SDK - #139900
Conversation
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.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 6, 2026, 5:22 AM ET / 09:22 UTC. ClawSweeper reviewWhat this changesThe 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 Review scores
Verification
How this fits togetherSession 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
Before merge
Agent review detailsSecurityNone. PR surfaceSource +7, Tests +333, Docs +7. Total +347 across 3 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest 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. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
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.
|
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 All 8,547 runtime files stayed unchanged during the compiled replay; manifest SHA256 |
|
Merged via squash.
|
…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.
What Problem This Solves
Session SDK selection could choose
Alphawhen the caller requested the distinct modelalpha, 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
b461b36233f81a0b86c9320cd2d6aee839c05ca4, committed asc49515c69621af70e744100c2f4331b119b8a666. 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.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.