Skip to content

fix(tui): keep model catalogs scoped to the selected agent - #139880

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

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

Conversation

@obviyus

@obviyus obviyus commented Sep 6, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #136257.

What Problem This Solves

The local terminal could show a selected agent but fail to load history, open its model picker, or change models when no ambient owner existed.

Why This Change Was Made

Local operations pass the resolved session or selected agent into the prepared catalog loader and wait for the current catalog publication. The obsolete history registry cache is removed. Existing model restrictions and Gateway-backed behavior remain intact.

User Impact

Users can select models, switch between agents with different restrictions, and continue or create sessions with the correct model. No configuration or storage change.

Evidence

Real CLI and terminal checks reproduced missing-owner errors before the fix. Afterward, history, model selection, agent switching, and new-session boundaries worked. Six recorded requests confirmed selected models and history boundaries. Three regressions failed before repair; all 191 focused tests passed afterward. Endpoints were synthetic; native sign-in and live external inference were not tested.

Consumers: local terminal history, picker, and model changes use the selected agent's catalog.

@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 self-assigned this Sep 6, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: S 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:16 AM ET / 07:16 UTC.

ClawSweeper review

What this changes

The local terminal passes the selected agent into model catalog loading, waits for catalog publication, and removes its cached history-specific plugin registry.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix: fetched main still loses the selected agent when acquiring local terminal catalogs. No blocking patch defect was found, and the broader related staging PR does not supersede this work.

Priority: P2
Reviewed head: d6576f7caef51e955847d7a3bbc3d0a4bde39ece

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-routing repair with meaningful regression coverage and reported terminal validation; no actionable correctness defect was found.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies a MEMBER-authored PR, exempt from the external-contributor gate; its body additionally reports built local-terminal before/after checks exercising the changed backend’s agent catalogs, model requests, and session boundaries.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies a MEMBER-authored PR, exempt from the external-contributor gate; its body additionally reports built local-terminal before/after checks exercising the changed backend’s agent catalogs, model requests, and session boundaries.
Evidence reviewed 6 items Verified patch boundary: The complete merge-base-to-head patch changes only the embedded backend and its tests. The supplied verified test merge also changes only those paths relative to its pinned main parent.
Current main still needs the repair: Fetched main's loadEmbeddedTuiModelCatalog accepts only config and invokes the Gateway catalog loader without an agent. The prepared catalog input resolver otherwise falls back to ambient ownership. Latest-release source could not be inspected from available objects, so no shipped-fix claim is made.
Existing owner-aware catalog contract: The Gateway loader already accepts agentId and getConfig and forwards them to the prepared catalog owner. The terminal picker already supplies its selected agent. This patch repairs the missing connection without adding a parallel catalog API or relying on a Codex dependency contract.
Findings None None.
Security None None.

How this fits together

The local terminal uses an embedded backend to load history and select models. That backend reads prepared model catalogs and applies the selected agent’s model policy before presenting choices or updating sessions.

flowchart TD
  A[Terminal agent selection] --> B[Embedded backend]
  C[Configuration publication] --> D[Publication readiness]
  B --> D
  D --> E[Selected agent catalog]
  E --> F[Agent model policy]
  F --> G[Model picker and session operations]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -16, Tests -7. Total -23 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 26 42 -16
Tests 1 55 62 -7
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 81 104 -23

Review metrics

None.

Technical review

Best possible solution:

Keep catalog construction in the shared prepared owner and consistently carry the selected agent through every embedded terminal consumer.

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

Yes, from source: configure multiple agents without an ambient owner and open the local terminal’s model picker for an explicitly selected agent; fetched main drops that agent before catalog acquisition. This review did not execute the scenario.

Is this the best way to solve the issue?

Yes. Forwarding the existing agent identity and reusing publication readiness repairs the consumer boundary while preserving configured replace-mode catalogs and model filtering.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This repairs history and model selection in the bounded local-terminal, explicit multi-agent workflow.
  • 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: The supplied repository state identifies a MEMBER-authored PR, exempt from the external-contributor gate; its body additionally reports built local-terminal before/after checks exercising the changed backend’s agent catalogs, model requests, and session boundaries.

Label justifications:

  • P2: This repairs history and model selection in the bounded local-terminal, explicit multi-agent workflow.
  • 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 supplied repository state identifies a MEMBER-authored PR, exempt from the external-contributor gate; its body additionally reports built local-terminal before/after checks exercising the changed backend’s agent catalogs, model requests, and session boundaries.

Evidence

What I checked:

  • Verified patch boundary: The complete merge-base-to-head patch changes only the embedded backend and its tests. The supplied verified test merge also changes only those paths relative to its pinned main parent. (src/tui/embedded-backend.ts:210, d6576f7caef5)
  • Current main still needs the repair: Fetched main's loadEmbeddedTuiModelCatalog accepts only config and invokes the Gateway catalog loader without an agent. The prepared catalog input resolver otherwise falls back to ambient ownership. Latest-release source could not be inspected from available objects, so no shipped-fix claim is made. (src/tui/embedded-backend.ts:224, 0c74e5e040d1)
  • Existing owner-aware catalog contract: The Gateway loader already accepts agentId and getConfig and forwards them to the prepared catalog owner. The terminal picker already supplies its selected agent. This patch repairs the missing connection without adding a parallel catalog API or relying on a Codex dependency contract. (src/gateway/server-model-catalog.ts:80, d6576f7caef5)
  • Publication and regression coverage: The existing publication host waits until its captured promise is still the newest publication. Changed tests exercise agent-specific catalog results, a replacement publication arriving during a wait, and publication failure; replace-mode and wildcard cases remain covered. Tests were inspected, not executed. (src/tui/embedded-backend.test.ts:1480, d6576f7caef5)
  • Supplied behavior evidence and related work: The captured PR body reports baseline/candidate built-terminal observations with two synthetic endpoint fixtures and six captured requests, covering agent switching, alternate model selection, continuation, and a fresh session. It also reports 191 focused passing tests. These are contributor-reported observations, not executions by this reviewer. feat(models): direct model lists and provider login across surfaces #136257 remains a broader open staging draft whose body explicitly anticipates smaller PRs. (d6576f7caef5)
  • Publication-owner history: Available history associates the embedded publication host with the local-runtime rebuild repair. Blame locates the current readiness comparison at this commit; this is a routing pointer, not independently established introduction attribution. (src/tui/embedded-prepared-runtime.ts:18, 25401e47582d)

Likely related people:

  • Jason (Json): Raw commit 25401e4 adds src/tui/embedded-prepared-runtime.ts:18 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 25401e47582d; files: src/tui/embedded-prepared-runtime.ts)
  • Peter Steinberger: 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

The only failed child in completed CI run 34018530835, attempt 1 is checks-node-compact-large-6. Its failure is unrelated to this PR.

  • src/agents/sandbox/browser.create.test.ts:606, “includes the explicit env policy epoch in the browser config hash when needed,” assumes the fixed /tmp/workspace has no protected skill mounts.
  • On unchanged main 2a488546aabe1921259e7d3a4f18be8f3741d77d, the exact test passes when /tmp/workspace/skills is absent and fails at the same assertion when only that directory is created in an isolated test container. Both complete results are retained. No source change was needed to reproduce it.
  • Production correctly includes existing protected mounts in its hash. 0d4eb03c035, from fix(sandbox): restore guest coding in private workspaces #135702, extended that behavior to private workspaces; its parent-relative change exposes this older empty-mount fixture assumption. Author and merger: @steipete; commit writer: GitHub. This does not imply the protected-mount behavior should be removed.
  • This PR changes only the terminal backend and its test. The sandbox hash, mount, environment, fixture, dependency and runner inputs are unchanged, and the failing sandbox shard does not run the terminal tests. The CI runner's actual directory contents were not captured; the isolated main reproduction establishes the failing condition.
  • A current matching main-run result was unavailable from the run queries. The retained unchanged-main reproduction supplies causal proof for the approved unrelated-CI route. Every other selected child completed without failure; the aggregate gate reflects this one failure.

Follow-up: give the sandbox hash fixture an isolated workspace or explicit mount inputs. That unrelated test repair is not included here. The exact-head local landing review passed at platinum/B with no findings, and the real terminal acceptance proof remains valid.

@obviyus

obviyus commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-unrelated-red
pr: 139880
head: d6576f7
run: 34018530835 attempt: 1
failed: checks-node-compact-large-6 job=101446816896 conclusion=failure
check: openclaw/ci-gate

@obviyus
obviyus merged commit 23a4791 into main Sep 6, 2026
180 of 182 checks passed
@obviyus
obviyus deleted the codex/core-consumer-catalog branch September 6, 2026 07:23
@obviyus

obviyus commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as 23a47913496c from reviewed head d6576f7caef.

  • Bug: local terminal history, model listing, and model changes lost the selected agent before catalog acquisition.
  • Fix: carry the resolved agent into the existing prepared catalog owner, await publication readiness, and remove the last-history registry cache.
  • Proof: 191 focused tests pass; three regression cases fail on unchanged main. Independent real-terminal checks cover agent restrictions, six model requests, actual alternate-model selection and switch-back, retained history, and a fresh /new conversation. Exact-head local and public reviews are platinum/B with no findings or rank-up actions.
  • Size: production -16, tests -7, total -23 lines.

The guarded merge used the approved unrelated-CI exception for run 34018530835, attempt 1. Its only failed child was checks-node-compact-large-6, job 101446816896: src/agents/sandbox/browser.create.test.ts:606, the explicit-env-policy config-hash assertion. Every other selected child passed.

The same test passes on unchanged main 2a488546aabe1921259e7d3a4f18be8f3741d77d without /tmp/workspace/skills, then fails when that directory alone exists. Its expected hash assumes no protected mounts; production includes them. 0d4eb03c035 (#135702; author/merger @steipete, commit writer GitHub) extended protected mounts to private workspaces and exposes that older fixture assumption. Sandbox code, test inputs, dependencies, and runner are unchanged by this terminal-only PR. A current matching main-run result was unavailable; complete isolated main reproduction supplies the causal proof. Follow-up: isolate the sandbox hash fixture's workspace.

The broader source draft remains untouched. No configuration, schema, protocol, or credential-persistence change is included.

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

Related: openclaw#136257

## What Problem This Solves

Fixes an issue where users selecting an agent in `openclaw tui --local` could not load history, open the model picker, or change models when multiple agents were configured without an ambient owner. The terminal showed the selected agent but reported that the operation had no explicit owner.

## Why This Change Was Made

Carry the resolved session or selected agent into the existing prepared catalog loader, and wait for the terminal's current catalog publication before catalog-consuming operations. Remove the last-history plugin registry cache: catalog construction already owns its registry scope. Keep explicit replace-mode catalogs, wildcard discovery, model restrictions, and Gateway-backed terminal behavior.

## User Impact

Users can choose a model for the selected agent, switch between agents with different model restrictions, and continue or create a session with the correct model.

## Evidence

| Scenario | Main at `b9a935ddedd` | This change at `d6576f7caef` |
| --- | --- | --- |
| Local terminal, two agents, explicit work session | History, model listing, and model changes report a missing owner | History loads; picker and model selection work |
| Switch work → main → work | Selected catalog acquisition is not scoped to the chosen agent | Each picker shows its agent's allowed model; requests use the chosen model |
| Continue work, then `/new` | Model selection is blocked | Continuation retains work history; new work session sends a request without prior conversation history |
| Choose a different allowed work model, then switch back | Model selection is blocked | Captured requests change from the alternate model to the original model while retaining conversation history |

- Real built CLI and terminal with isolated synthetic model endpoints; six captured requests across two fixtures confirm model selection and session history boundaries. Independent validators exercised the terminal without reading implementation source, including a switch to a different allowed model and back.
- All 191 focused tests pass: terminal backend/client, prepared catalog owner, and Gateway catalog projection. Three regression cases fail on unchanged main.
- Syntax-only focused lint, pinned formatting, changed-scope line/assertion checks, and independent code review pass. Both baseline and candidate builds complete.
- Production: 16 lines removed net. Tests: 7 lines removed net. Total: 23 lines removed net. No configuration, schema, protocol, or credential-persistence changes.

Publication ordering, paired auth state, and alternate catalog modes are covered by owner tests and code review; the terminal exercise does not claim live external-provider or native sign-in validation.

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

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: S 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