Skip to content

fix: preserve exact model identity in SDK catalog lookups - #139907

Merged
obviyus merged 2 commits into
mainfrom
codex/exact-model-identity
Sep 6, 2026
Merged

obviyus merged 2 commits into
mainfrom
codex/exact-model-identity

Conversation

@obviyus

@obviyus obviyus commented Sep 6, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #136257.

What Problem This Solves

Plugin model lookup could return a different model when identifiers differed only by case. This is public developer-interface hardening; no channel or Gateway failure was reproduced.

Why This Change Was Made

Shared lookup scopes the provider first and prefers exact identity. The existing case-insensitive fallback applies only when it identifies one row. Provider aliases, exact duplicate precedence, and the public signature remain intact.

User Impact

Plugins receive the requested model's metadata regardless of catalog order. Ambiguous requests return no match. Compatibility decision.

Evidence

Public-package checks reproduced the wrong identity on main and release 2026.9.2. The fix returned each exact row in either order and rejected ambiguous lookup. Four regressions failed before the change; all 233 focused tests passed afterward. Public acceptance covered 77 lookups and three catalog builds. Local CLI inference controls used a synthetic endpoint.

Consumers: public model lookup now applies exact precedence and rejects ambiguous fallback.

@obviyus obviyus self-assigned this Sep 6, 2026
@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 agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 6, 2026
@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
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 6, 2026, 4:03 AM ET / 08:03 UTC.

ClawSweeper review

What this changes

Model catalog lookups prefer exact canonical IDs, retain unique case-insensitive matches, reject ambiguous matches, and consolidate identity and thinking regression coverage.

Merge readiness

⛔ Blocked before merge - 1 item remains

This remains a useful, bounded fix: current main and the latest release retain the reported lookup defect. No introduced correctness or security findings remain, and the discussion resolves the previous compatibility decision.

Priority: P2
Reviewed head: e1e034831e055fa68d1cf5743791531c9a9ed334

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful regression coverage, unchanged production since the prior review, and an explicitly accepted compatibility tradeoff.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository State identifies a MEMBER-authored PR, so the external-contributor gate does not apply. The body records before/after built public-SDK lookup results for the changed owner; production source is unchanged from that tested revision, and no authority-bearing behavior changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository State identifies a MEMBER-authored PR, so the external-contributor gate does not apply. The body records before/after built public-SDK lookup results for the changed owner; production source is unchanged from that tested revision, and no authority-bearing behavior changes.
Evidence reviewed 8 items Current main still contains the defect: The qualified lookup lowercases IDs and returns the first matching row, so Reader preceding reader causes an exact reader request to select Reader.
Latest release has the same lookup behavior: The supplied v2026.9.2 release commit also contains first-row, case-insensitive qualified lookup; this is not an already-shipped fix.
Existing identity owner reused: The patch uses resolveModelCatalogIdentityKey, whose fallback preserves model-ID case and whose OpenAI equivalence delegates to the repository-owned provider policy. This catalog contract does not establish dependence on an external Codex runtime or protocol.
Findings None None.
Security None None.

How this fits together

OpenClaw’s model catalog supplies model metadata to plugins and runtime consumers. These lookup helpers select a catalog record from a provider and model ID, affecting capability and model-selection decisions.

flowchart TD
  A[Plugin or runtime request] --> B[Provider and model ID]
  C[Model catalog records] --> D[Provider filtering]
  B --> D
  D --> E[Canonical identity match]
  E -->|Found| F[Selected model metadata]
  E -->|Missing| G[Unique case insensitive match]
  G -->|Unique| F
  G -->|Ambiguous or absent| H[No match]
Loading

Before merge

  • Resolve merge risk (P1) - External plugins relying on arbitrary first-row selection for ambiguous, non-exact IDs will now receive undefined and may need to supply the exact ID. That compatibility correction is explicitly accepted; unknown third-party reliance remains unmeasured.
Agent review details

Security

None.

PR surface

Source +13, Tests +54. Total +67 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 21 8 +13
Tests 2 132 78 +54
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 153 86 +67

Review metrics

Metric Value Why it matters
Production and regression growth Production net +13 lines; tests net +54 lines after consolidation Production growth implements exact precedence and ambiguity handling; the existing thinking coverage is preserved.

Merge-risk options

Maintainer options:

  1. Retain the accepted ambiguity correction (recommended)
    Proceed with the documented contract that ambiguous non-exact SDK requests return no match and callers supply the intended exact ID.

Technical review

Best possible solution:

Keep one canonical identity lookup with the existing SDK signature, unique case-insensitive compatibility, and the explicitly accepted ambiguity correction.

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

Yes: current-main source deterministically selects Reader for an exact reader request when Reader appears first. The PR records matching public-package reproduction; this review did not execute it.

Is this the best way to solve the issue?

Yes: repairing the shared lookup with the existing canonical identity owner is narrow, preserves unique fallback behavior, and avoids introducing another SDK path.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This fixes a bounded SDK metadata-selection defect without evidence of an urgent channel or Gateway outage.
  • merge-risk: 🚨 compatibility: Ambiguous non-exact SDK requests change from arbitrary selection to undefined, an explicitly accepted caller-visible correction.
  • 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: Repository State identifies a MEMBER-authored PR, so the external-contributor gate does not apply. The body records before/after built public-SDK lookup results for the changed owner; production source is unchanged from that tested revision, and no authority-bearing behavior changes.

Evidence

What I checked:

  • Current main still contains the defect: The qualified lookup lowercases IDs and returns the first matching row, so Reader preceding reader causes an exact reader request to select Reader. (src/agents/model-catalog-lookup.ts:150, 379f0533efb9)
  • Latest release has the same lookup behavior: The supplied v2026.9.2 release commit also contains first-row, case-insensitive qualified lookup; this is not an already-shipped fix. (src/agents/model-catalog-lookup.ts:150, 3928bad9badf)
  • Existing identity owner reused: The patch uses resolveModelCatalogIdentityKey, whose fallback preserves model-ID case and whose OpenAI equivalence delegates to the repository-owned provider policy. This catalog contract does not establish dependence on an external Codex runtime or protocol. (src/agents/openai-model-routes.ts:71, e1e034831e05)
  • Public SDK and configured catalog boundary: The agent-runtime SDK exports findModelInCatalog, while buildConfiguredModelCatalog constructs individual configured model rows. The repair changes selection within that existing API without adding a competing API or configuration option. (src/agents/model-selection-shared.ts:1367, e1e034831e05)
  • Re-review continuity: The targeted comparison against the earlier reviewed head is empty for production lookup code, package.json, and pnpm-lock.yaml. Both revisions identify the lookup source as blob 4eabbf6533cc33438e4839e4f7e7a00555f6cfac. The complete new suite preserves all eight original thinking cases and adds five identity cases. (src/agents/model-catalog-lookup.test.ts:12, e1e034831e05)
  • Compatibility disposition: The captured discussion explicitly accepts requiring an exact ID when multiple case-distinct records match a non-exact request: fix: preserve exact model identity in SDK catalog lookups #139907 (comment). Repository State identifies the author as MEMBER; this resolves the earlier review’s decision request rather than creating another blocker.

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • pash-openai: 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 (1 earlier review cycle)
  • reviewed 2026-09-06T07:46:54.661Z sha 1b01c05 :: blocked before merge. :: none

@obviyus

obviyus commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator Author

Accepting the documented ambiguity correction for this scoped repair.

The public SDK keeps its existing signature and accepts uniquely identifiable case-insensitive requests. When multiple case-distinct identities match a non-exact request, the caller must supply the intended exact ID. Returning an arbitrary record would preserve the reported metadata-selection defect.

The current-main and published-package probes establish the prior behavior; the candidate public-package and independent acceptance probes establish exact selection, unique fallback compatibility, and explicit ambiguity. No claim is made that unknown third-party callers have been exhaustively audited. This bounded compatibility change is explicit in the PR's User Impact and is part of the approved exact-identity extraction.

This addresses the compatibility decision in #139907 (comment). The review reports no code or security findings and no rank-up changes. The clean exact-head local review reaches the same technical result. No source or PR-body change is needed.

@obviyus
obviyus merged commit b561409 into main Sep 6, 2026
182 of 183 checks passed
@obviyus
obviyus deleted the codex/exact-model-identity branch September 6, 2026 08:04
@obviyus

obviyus commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in b561409.

SDK hardening: exact provider/model identity now wins before the uniquely identifiable case-insensitive fallback. Ambiguous requests return no match instead of another model's record.

Before After
reader can select Reader, depending on catalog order. Each exact ID selects its own record in either order.
Ambiguous READER selects the first row. Ambiguity returns no match; unique legacy fallback still works.
  • Built public SDK baseline/stable reproduction and candidate proof pass the intended red/green checks; independent acceptance covers 77 lookups and three configured builds.
  • 233 focused/sibling tests pass. All 13 identity/thinking cases remain in one owner suite; the candidate-caused test-root limit failure is fixed without changing the limit.
  • Final head e1e034831e055fa68d1cf5743791531c9a9ed334 has green CI: https://github.com/openclaw/openclaw/actions/runs/34020419882. Exact-head local review is platinum/B with no findings or rank-up changes. No CI exception was used.
  • Runtime proof remains bound to 1b01c0561a5928ab62f383ff9f94972c5eb7d440; the final revision only consolidates tests. The command-line controls establish fixture-backed compatibility, not a live-provider or Gateway/channel defect.

The documented ambiguity compatibility choice is accepted in #139907 (comment). Source draft #136257 remains separate and untouched.

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

Prefer canonical exact model identity before the unique case-insensitive SDK fallback. Keep provider boundaries and providerless ambiguity explicit.

SDK hardening proved through the built public package, baseline regressions, sibling tests, and isolated command-line compatibility controls.

Co-authored-by: Ayaan Zaidi <[email protected]>
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 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