Skip to content

fix(gateway): keep CLI session model identities consistent - #139884

Merged
obviyus merged 1 commit into
mainfrom
codex/gateway-consumer-catalog
Sep 6, 2026
Merged

obviyus merged 1 commit into
mainfrom
codex/gateway-consumer-catalog

Conversation

@obviyus

@obviyus obviyus commented Sep 6, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #136257.

What Problem This Solves

CLI-backed sessions could show inconsistent model providers in lists, details, and patch responses. Searching by the actual provider could miss the session.

Why This Change Was Made

One Gateway projection uses the backend's declared model provider for display identity. Lists, defaults, details, search, and patch responses share it. Runtime policy retains the original selected route.

User Impact

Session identity agrees across read surfaces, and provider/model search finds the session. Qualified and standalone backend identities remain intact. Stored selections do not change.

Evidence

Built Gateway requests reproduced mismatched identities and missing search results before the fix. Three regressions failed before the repair; all 246 focused tests passed afterward. API acceptance checked identity, search, label-only edits, changed defaults, and preserved selections across 117 request/response pairs. Inference was not tested.

Consumers: session lists, details, defaults, search, and patch responses share declared display identity.

AI-assisted.

@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.

@obviyus
obviyus marked this pull request as ready for review September 6, 2026 07:14
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Sep 6, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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: needs maintainer review before merge. Reviewed September 6, 2026, 3:21 AM ET / 07:21 UTC.

ClawSweeper review

What this changes

The Gateway consistently displays CLI-backed session models using the backend’s declared provider while preserving the selected route for runtime and catalog policy.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused repair: current main still guesses CLI display providers and projects inconsistent identities. No actionable introduced defect was found, and the related staging draft does not supersede this PR.

Priority: P2
Reviewed head: f29a4e100a3040db6904b8cc0b27f07d2fac328c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful regression coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository State identifies a MEMBER-authored PR, so the ordinary contributor proof gate does not apply; no material authority change triggers an exception. The captured body additionally reports built-Gateway before/after identity, search, and label-patch observations at the reviewed candidate.
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 ordinary contributor proof gate does not apply; no material authority change triggers an exception. The captured body additionally reports built-Gateway before/after identity, search, and label-patch observations at the reviewed candidate.
Evidence reviewed 8 items Current main still contains the reported mechanism: The fetched main revision still resolves CLI display identities through the agent default and configured-model inference. This can substitute an unrelated provider for a mapped or standalone CLI selection.
Existing descriptor contract supplies the identity: The existing canonical-provider resolver reads registered backend modelProvider metadata, then optionally resolves the specific setup descriptor. The patch reuses this contract and preserves unmapped backend identities.
Display and execution policy remain separate: Rows use the selected route for runtime, fallback, thinking, catalog, and context calculations; only the returned model identity uses the display projection. Defaults and patch responses follow the same separation.
Findings None None.
Security None None.

How this fits together

The Gateway projects stored session selections and agent defaults into session lists, details, search results, and patch responses. CLI backend descriptors supply display identities, while the selected route continues to determine runtime and context metadata.

flowchart TD
  A[Session selections and agent defaults] --> B[Selected model route]
  B --> C[Display identity projection]
  D[CLI backend descriptors] --> C
  C --> E[Lists details search and patch responses]
  B --> F[Runtime and catalog policy]
  F --> E
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -17, Tests +102. Total +85 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 41 58 -17
Tests 1 102 0 +102
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 143 58 +85

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net -17 lines; tests +102 lines Reusing the existing descriptor resolver removes provider guessing while adding cross-surface coverage without a new production test seam.

Technical review

Best possible solution:

Use one descriptor-based display projection across session reads while retaining selected-route ownership of runtime and context metadata.

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

Yes, source provides a high-confidence path: select a mapped or standalone CLI backend while the agent has an unrelated default, then compare list, detail, and patch identities. This reviewer did not execute that path.

Is this the best way to solve the issue?

Yes. Reusing declared backend metadata removes unsupported provider inference, and separating display identity from selected-route policy preserves the relevant existing contracts.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: The repair addresses incorrect CLI session identity and search results without changing stored selections or execution routing.
  • 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: Repository State identifies a MEMBER-authored PR, so the ordinary contributor proof gate does not apply; no material authority change triggers an exception. The captured body additionally reports built-Gateway before/after identity, search, and label-patch observations at the reviewed candidate.

Label justifications:

  • P2: The repair addresses incorrect CLI session identity and search results without changing stored selections or execution routing.
  • 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 ordinary contributor proof gate does not apply; no material authority change triggers an exception. The captured body additionally reports built-Gateway before/after identity, search, and label-patch observations at the reviewed candidate.

Evidence

What I checked:

  • Current main still contains the reported mechanism: The fetched main revision still resolves CLI display identities through the agent default and configured-model inference. This can substitute an unrelated provider for a mapped or standalone CLI selection. (src/gateway/session-utils-model.ts:633, 38d31ee66dd3)
  • Existing descriptor contract supplies the identity: The existing canonical-provider resolver reads registered backend modelProvider metadata, then optionally resolves the specific setup descriptor. The patch reuses this contract and preserves unmapped backend identities. (src/agents/cli-backends.ts:188, f29a4e100a30)
  • Display and execution policy remain separate: Rows use the selected route for runtime, fallback, thinking, catalog, and context calculations; only the returned model identity uses the display projection. Defaults and patch responses follow the same separation. (src/gateway/session-utils-row.ts:200, f29a4e100a30)
  • Behavioral regression matrix: The complete new test covers mapped CLI, standalone CLI, qualified identity, and direct-provider controls across full/lightweight rows, patch responses, search, and defaults. It checks retained runtime policy without adding a production test seam. Existing selected-route context-window assertions were also inspected. (src/gateway/session-utils-model.identity.test.ts:17, f29a4e100a30)
  • Implementation boundary: The CLI backend documentation identifies plugin-owned backend registrations and distinguishes them from the Codex app-server harness. This patch changes generic OpenClaw display projection and does not depend on a Codex runtime or protocol contract. Public docs: docs/gateway/cli-backends.md. (docs/gateway/cli-backends.md:239, f29a4e100a30)
  • Captured production validation and related work: The supplied PR body reports baseline/candidate built-Gateway observations for mapped, standalone, qualified, default, search, and label-only patch scenarios, plus 117 request/response pairs and 20 session events. These are reported observations, not reviewer execution. Captured context sourceRevision is 5cbe0f4739b24f9d331c6260229a9c8d0c3bd40eb163f2ef64be1969237094e0. The related feat(models): direct model lists and provider login across surfaces #136257 remains an open staging draft describing a broader catalog/login program and planned splitting into smaller PRs. (f29a4e100a30)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: 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.

@obviyus

obviyus commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator Author

Ready for guarded landing at f29a4e100a3040db6904b8cc0b27f07d2fac328c under the standing unrelated-CI-failure approval.

  • Local exact-head ClawSweeper gate: platinum/B, proof A, no findings, security concerns, or rank-up requests. The latest public review also reports platinum/B and no before-merge requests.
  • Built Gateway baseline/candidate probes and fresh API-only acceptance cover lists, details, defaults, search, label patches, events, and changed-default/restoration controls. Inference and unlogged work are outside the observed proof; those limits remain in the PR body.
  • node scripts/run-vitest.mjs src/gateway/session-utils-model.identity.test.ts src/gateway/session-utils.test.ts: 246 pass. ACP-owner and resolver-cache sibling checks pass. Focused run-oxlint.mjs --openclaw-focused-config, pinned formatter, max-lines and assertion-safety checks pass. CI's type and lint checks pass.

CI run 34018634689, attempt 1, is complete: 105 jobs succeeded. The sole failed child is checks-node-compact-large-6 / 101447095020. The summary gate / 101447913113 fails only because of that child.

The child fails src/agents/sandbox/browser.create.test.ts:606, “includes the explicit env policy epoch in the browser config hash when needed.” Its agents-support shard reports 1 failed, 1264 passed, and 2 skipped. The helper at lines 162–194 assumes readOnlyWorkspaceSkillMounts: [], while the test uses fixed /tmp/workspace. Production includes existing protected skill mounts in its hash.

Independently supplied baseline controls on unmodified main 2a488546aabe1921259e7d3a4f18be8f3741d77d pass without /tmp/workspace/skills and fail with the same assertion after creating only that directory in a disposable fixture. I read the complete controls and checked their sandbox source bytes against the pinned baseline. I reused that experiment and did not change shared temporary state or sandbox code. The actual CI directory contents were not captured.

The relevant mount behavior comes from #135702, private workspace skill protection, commit 0d4eb03c0357b0e2570680ce76f083b85dfd2fd4, already ancestral to the baseline. Its parent-relative change makes private workspace skill mounts participate in the hash; the fixed-path test retains an empty-mount assumption. This identifies stale test setup, not an incorrect security behavior.

This PR does not change sandbox/hash/mount code, dependencies, or test configuration. Its Gateway test uses an isolated temporary state directory and does not run in the failing agents-support shard. The sandbox hash path consumes unchanged sandbox config, constants, environment policy, and mount state; no changed Gateway projection enters it. I judge the failed child and its derived gate failure unrelated to this repair. A matching recent main CI run is not claimed; the guarded approval uses the retained causal baseline proof.

Follow-up outside this PR: give the sandbox hash test an isolated workspace or an explicit mount expectation. Production is net −17 lines; regression coverage adds 102 lines. No source-draft, protocol, auth, config, or schema mutation is included.

@obviyus

obviyus commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-unrelated-red
pr: 139884
head: f29a4e1
run: 34018634689 attempt: 1
failed: checks-node-compact-large-6 job=101447095020 conclusion=failure
check: openclaw/ci-gate

@obviyus
obviyus merged commit 865055d into main Sep 6, 2026
243 of 245 checks passed
@obviyus
obviyus deleted the codex/gateway-consumer-catalog branch September 6, 2026 07:27
@obviyus

obviyus commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as 865055d1da5a0d096f232aef3b156e60ee49b311.

Proof: actual built Gateway before/after requests, 246 affected tests, and fresh API-only acceptance with 117 request pairs and 20 session events. Local and public ClawSweeper reviews are platinum/B with no findings. Inference and unlogged work remain outside the observed proof.

Before After
CLI selections display a runtime alias or an unrelated default provider across session reads. Lists, details, defaults, events, search, and patch responses use the declared provider identity.
Canonical provider search misses mapped CLI selections. Search finds them while stored selections and route metadata remain intact.

CI exception: completed run 34018634689, attempt 1 has 105 successful jobs. Its sole failed child, checks-node-compact-large-6 / 101447095020, fails the sandbox browser hash fixture at src/agents/sandbox/browser.create.test.ts:606; the summary gate / 101447913113 reflects that failure.

The matching failure was reproduced on unchanged main with only a preexisting temporary skills directory, and the relevant source bytes and ancestry were checked. The fixture assumes no mounts despite the existing protected-mount behavior from #135702. This PR changes none of those inputs. Complete causal assessment and standing approval bound to the exact completed run were validated by the guarded merger. No recent matching main CI run or direct observation of the CI runner's directory contents is claimed.

Production net −17 lines; tests +102. The broader source draft remains unchanged. The sandbox fixture isolation follow-up stays outside this extraction.

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

Related: openclaw#136257

## What Problem This Solves

Sessions selected through a CLI backend can show different model providers in the session list, details, and patch response. Details can borrow the unrelated agent default, and searching by the actual provider can miss the session. Standalone backends can also lose their own identity.

## Why This Change Was Made

The Gateway uses the existing backend's declared model provider for display identity. Lists, defaults, details, search, and patch responses share that projection. Catalog and runtime policy keep the original selected route, including existing CLI-specific context metadata.

Removed provider guessing from agent defaults/configured model names, the lightweight-row bypass, and the obsolete agent-specific display cache key. This is an existing read-surface repair; it adds no protocol fields, authentication mutation, configuration option, or storage change.

## User Impact

- Model provider and model identity agree across session reads.
- Provider/model search includes sessions selected through their CLI backend.
- Qualified identities and standalone backend names remain intact.
- Stored selections, runtime policy, and selected-route catalog metadata keep their owners.

## Evidence

The actual built Gateway was tested with the bundled Claude CLI descriptor and two isolated fixture backends. All requests used synthetic state without inference or operator credentials.

| Existing API scenario | Baseline | Candidate |
| --- | --- | --- |
| List and describe one mapped CLI selection | CLI name in list; unrelated default provider in details | Declared provider in both |
| Standalone CLI details | Unrelated default provider | Standalone backend identity |
| Qualified CLI selection | Different list/detail identities | Same qualified identity |
| CLI agent default | Runtime alias shown as provider | Declared model provider |
| Provider/model search | Mapped CLI selection omitted | Selection included |
| Label-only session patch | Unrelated provider in response | Declared provider; selection unchanged |

Baseline `b9a935ddeddc5e6545135912a69bee6f7051e90a`; candidate `f29a4e100a3040db6904b8cc0b27f07d2fac328c`. Three new regression cases fail on the original production code; the direct-provider control passes. All 246 affected identity/session tests pass after the repair. Existing context-window assertions remain unchanged. ACP ownership and resolver-cache checks also pass. Focused syntax lint, pinned formatting, assertion-safety and max-lines checks pass. Type checks run in CI.

A fresh source-blind, API-only validator exercised 117 complete request/response pairs and 20 real session events. Identity, search, label-patch, standalone/qualified controls, and changed-default/restoration checks pass. It found no observable model-identity failure. Retained selection fields remain unchanged. Inference was intentionally excluded; APIs/logs cannot prove absence of unlogged work. Build isolation and historical baseline provenance are supplied by the repair owner, not claimed as independently discoverable through the API. An earlier validator inspected the synthetic database schema; its evidence is retained only as supplemental proof, not as the source-blind gate.

Production: **+41/-58, net -17**. Tests: **+102**. Total: **+85**. No generated, lockfile, or docs changes. The added regression matrix checks full/lightweight rows, patch responses, defaults, search, and retained runtime policy at existing boundaries; it adds no test-only production seam. No existing coverage was removed.

AI-assisted.

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

gateway Gateway runtime maintainer Maintainer-authored PR 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