Skip to content

fix: recover new-session models through Gateway startup - #119120

Merged
steipete merged 6 commits into
mainfrom
codex/fix-new-session-metadata
Aug 4, 2026
Merged

steipete merged 6 commits into
mainfrom
codex/fix-new-session-metadata

Conversation

@steipete

@steipete steipete commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Closes #118891.
Closes #119105.
Related: #116118
Supersedes #118893 because its contributor fork branch became unwritable after the maintainer proof commits; the replacement preserves both original commits and contributor credit.

What Problem This Solves

Users opening New Session can lose their valid configured model catalog when optional text-command metadata fails or the first chat.metadata request arrives while Gateway startup sidecars are still initializing.

Why This Change Was Made

The Gateway now treats configured models as required metadata and text commands as optional metadata. It captures synchronous command enumeration failures, logs them, and returns the valid model catalog without commands. Model discovery failures remain fatal.

The Control UI retries only the canonical retryable startup-sidecars UNAVAILABLE response. Retries respect the server delay, abort when the owning Lit task is invalidated, and stop after 60 seconds. Unrelated errors still fail immediately.

This does not weaken exec-approval migration checks, modify model configuration, or retry arbitrary failures. Direct inspection of @lit/task 1.0.3 confirmed that starting a new task aborts the previous signal and stale task results do not invoke completion/error callbacks.

The branch also repairs the unrelated current-main auth-transport E2E failure that blocked exact-head CI twice. Successful connected shells start background Gateway bootstrap RPCs that can outlive browser-context teardown; the test now exercises rejection paths first, runs the full connected shell last, closes every context explicitly, and captures page errors before navigation. No timeout was enlarged and no assertion was weakened.

User Impact

New Session keeps the complete configured model catalog through unrelated command-metadata failures and recovers automatically from the bounded Gateway startup window. Real model-catalog failures remain visible.

Evidence

Exact candidate head: 44fb886a59434def2b58f4ba282fee9df1730767.

  • Blacksmith Testbox run 30874479489, lease tbx_01kz5ck73tzdghk3v3zdyn7e9s:
    • pnpm test ui/src/e2e/new-session-page.catalog-reconnect.e2e.test.ts ui/src/pages/new-session/model-control.test.ts src/gateway/server.chat.gateway-server-chat-b.test.ts
    • 97 Gateway tests, 15 Control UI controller tests, and 5 Chromium New Session E2Es passed (117 total).
    • The new rendered-browser case passed in 753 ms, made exactly two chat.metadata requests for agent main, opened the picker, and found the uniquely recovered model.
    • pnpm check:changed passed the core, coreTests, and ui lanes.
    • pnpm build passed, including the production Control UI build, precompressed-asset validation, and performance guard.
  • Blacksmith Testbox run 30875380025, lease tbx_01kz5dnv26szt9mbwqcxvg76v5: 97/97 Gateway tests passed after the final public-model fixture cleanup.
  • Auth-transport CI repair (issue #119105):
    • Constrained repro 30877133611: the focused file failed under one CPU after the connected shell's bootstrap RPCs continued for 102–106 seconds.
    • Constrained lifecycle candidate 30877503163: rejection-first ordering proved the lifecycle diagnosis, but full fork CI then exposed the remaining source-Vite and abandoned-root-work producers.
    • Final constrained candidate 30879271566: the same one-CPU command passed both scenarios after replacing the second Vite server with a built-UI origin proxy and awaiting the canonical Gateway root-work drain; no timeout changed.
  • Full-branch AutoReview against origin/main: clean, no accepted/actionable findings, confidence 0.97.
  • git diff --check and targeted oxfmt --check passed.
  • Public-model identifier audit: all added model IDs resolve in official provider docs: Luna, Sol, and Terra.
  • Original-PR CI run 30877888190 proved the intermediate lifecycle reorder and exposed the remaining source-Vite bottleneck. Replacement exact-head CI run 30879745188 is green, including all four Control UI E2E shards.
{
  "head": "44fb886a59434def2b58f4ba282fee9df1730767",
  "overall_behavior": "satisfies_contract",
  "overall_confidence": 0.98,
  "checks": {
    "optional_command_failure_preserves_models": "pass",
    "required_model_failure_remains_fatal": "pass",
    "canonical_startup_retry_count": 2,
    "rendered_recovered_model_visible": "pass",
    "noncanonical_error_no_retry": "pass",
    "task_invalidation_aborts_wait": "pass",
    "retry_deadline_60_seconds": "pass"
  },
  "blockers": []
}

Scope and safety

Six files, +488/-69. Production is +110/-7; tests are +378/-62. The production growth pays for one explicit required-versus-optional Gateway owner boundary and one cancellable, deadline-bounded Control UI startup retry. The additional current-main CI repair is test-only. No config, protocol, storage, dependency, workflow, version, signing, credential, or user-data surface changes.

Contributor credit: this branch preserves the two original commits authored by @ZYV5ge.

AI-assisted: yes.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Aug 4, 2026
@steipete
steipete marked this pull request as ready for review August 4, 2026 05:08
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 4, 2026
@clawsweeper

clawsweeper Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 4, 2026, 1:15 AM ET / 05:15 UTC.

ClawSweeper review

What this changes

This PR preserves the New Session model picker when optional command metadata fails, retries only the canonical Gateway-startup response, and stabilizes the related Control UI auth-transport E2E lifecycle.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open. The PR remains necessary because current main couples required model discovery to optional command enumeration; the proposed owner-boundary repair and focused Gateway/UI coverage show no blocking defect. Its protected maintainer label and active exact-head checks keep the merge decision human-owned.

Priority: P1
Reviewed head: 44fb886a59434def2b58f4ba282fee9df1730767
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with real browser and Gateway evidence, pending only the remaining exact-head CI and maintainer merge judgment.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body provides exact-head Testbox evidence including a rendered Chromium New Session recovery and focused Gateway behavior results.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body provides exact-head Testbox evidence including a rendered Chromium New Session recovery and focused Gateway behavior results.
Evidence reviewed 7 items Current-main defect: Current main uses Promise.all for model and command metadata, so either rejection fails the whole chat.metadata response.
Gateway owner-boundary repair: The candidate keeps model discovery fatal but logs and omits failed optional commands, preserving the valid configured catalog.
Gateway contract coverage: A real Gateway WebSocket harness proves command failure preserves models and a model-discovery failure still returns UNAVAILABLE.
Findings None None.
Security None None.

How this fits together

The Control UI asks Gateway for configured models and text commands before rendering New Session choices. Gateway supplies that metadata, while the UI turns the returned model catalog into the operator's model picker.

flowchart TD
A[New Session page] --> B[Control UI metadata request]
B --> C[Gateway metadata assembly]
C --> D[Configured model catalog]
C --> E[Optional text commands]
D --> F[Model picker]
E --> F
C --> G[Startup unavailable response]
G --> B
Loading

Decision needed

Question Recommendation
After exact-head CI finishes, should this maintainer-labeled replacement PR be accepted as the landing path for the New Session metadata repair? Sponsor the replacement: Merge this PR after its exact-head checks complete green, then retire the superseded predecessor PR.

Why: The protected maintainer label requires an explicit human merge judgment even though the code review found no mechanical blocker.

Before merge

  • Resolve merge risk (P1) - The branch is behind main and the remaining exact-head checks are still running, so merge should wait for the final integration result.
  • Resolve merge risk (P1) - The checkout lacks the pinned @lit/task source and network access prevented an independent upstream read of its cancellation implementation; the candidate’s task-invalidation coverage should remain part of exact-head validation.
  • Complete next step (P2) - No narrow repair remains; wait for the active exact-head checks and the required maintainer review of this protected PR.
Agent review details

Security

None.

PR surface

Source +103, Tests +316. Total +419 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 2 110 7 +103
Tests 4 378 62 +316
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 488 69 +419

Review metrics

Metric Value Why it matters
Production versus test delta production +110/-7; tests +378/-62 The production growth implements the required-versus-optional metadata boundary and bounded task-owned retry, while most changed lines are regression proof.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/gateway/server.chat.gateway-server-chat-b.test.ts, vector/embedding metadata: src/gateway/server-methods/chat-history-handler.ts, vector/embedding metadata: src/gateway/server.chat.gateway-server-chat-b.test.ts, vector/embedding metadata: ui/src/e2e/new-session-page.catalog-reconnect.e2e.test.ts, vector/embedding metadata: ui/src/pages/new-session/model-control.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Merge this replacement for fix: preserve new-session models through startup errors #118893 after exact-head checks pass and a maintainer approves it, retaining fatal behavior for genuine configured-model failures.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Merge this replacement for #118893 after exact-head checks pass and a maintainer approves it, retaining fatal behavior for genuine configured-model failures.

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

Yes. Current main’s coupled Promise.all path and one-shot New Session request establish the failure path, and the PR body records focused Gateway and rendered-browser after-fix runs.

Is this the best way to solve the issue?

Yes. Separating required model discovery from optional commands at Gateway and retrying only the typed startup response is narrower and safer than a generic UI retry.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5a1daf81a554.

Labels

Label changes:

  • add P1: The defect can prevent users from selecting already-configured models in the New Session flow and also affects a required Control UI E2E path.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-head Testbox evidence including a rendered Chromium New Session recovery and focused Gateway behavior results.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides exact-head Testbox evidence including a rendered Chromium New Session recovery and focused Gateway behavior results.

Label justifications:

  • P1: The defect can prevent users from selecting already-configured models in the New Session flow and also affects a required Control UI E2E path.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides exact-head Testbox evidence including a rendered Chromium New Session recovery and focused Gateway behavior results.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-head Testbox evidence including a rendered Chromium New Session recovery and focused Gateway behavior results.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Current-main history attributes the metadata handler and original auth-transport E2E to Vincent Koc. (role: recent area contributor; confidence: high; commits: a492eb90684a, 0dc99706243e; files: src/gateway/server-methods/chat-history-handler.ts, ui/src/e2e/control-ui-auth-transports.e2e.test.ts)
  • steipete: The PR’s final lifecycle commits and the related auth-transport report connect this contributor to the current E2E repair beyond merely opening the PR. (role: current repair and incident contributor; confidence: medium; commits: 3675617a937a, 44fb886a5943; files: ui/src/e2e/control-ui-auth-transports.e2e.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let the remaining exact-head checks finish green before merge.

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.

@steipete

steipete commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 44fb886a59434def2b58f4ba282fee9df1730767.

  • Root cause: chat.metadata coupled required configured-model discovery to optional command enumeration, while New Session made a single metadata request. Separately, the new auth-transport E2E started a second Vite compiler and began later browser interactions while successful-shell Gateway root work intentionally remained active after socket teardown.
  • Architectural owners: Gateway metadata aggregation, the New Session Task lifecycle, and the auth-transport test's browser/Gateway cleanup boundary.
  • Canonical fix: keep model discovery fatal; log and omit only failed optional commands; retry only typed startup-sidecars responses with Task cancellation and a 60-second aggregate deadline; reuse the built Control UI for the rejected Origin and await waitForActiveGatewayRootWork() after successful shells.
  • Removed paths/work: no parallel runtime path or compatibility shim. The E2E removes the second source Vite server and its warmup flow. No timeout or assertion was weakened.
  • Delta: six files, +488/-69. Production +110/-7; tests +378/-62. Production growth is limited to the explicit metadata owner boundary and cancellable bounded retry.
  • Sibling coverage: genuine model failure remains UNAVAILABLE; noncanonical retryable errors do not retry; Task invalidation aborts pending waits; the deadline shrinks request timeouts; trusted-proxy required-header and allowed-Origin enforcement remain asserted.

Proof:

  • Blacksmith 30874479489: 97 Gateway + 15 controller + 5 Chromium New Session tests passed; pnpm check:changed and pnpm build passed. The rendered recovery case made exactly two metadata requests and exposed the unique recovered model.
  • Blacksmith 30875380025: 97/97 Gateway tests passed after public-model fixture cleanup.
  • Blacksmith 30877133611: constrained auth lifecycle failure reproduced with 102–106 second abandoned-request work.
  • Blacksmith 30879271566: the same one-CPU command passed both final auth scenarios with no timeout change.
  • AutoReview: full branch clean, no accepted/actionable findings, confidence 0.97.
  • Exact-head CI 30879745188: green, including all four Control UI E2E shards.
  • Exact-head ClawSweeper review: proof sufficient, no findings. Its only Rank-up move was to let exact-head CI finish green; that is satisfied.
  • Repo-native review artifacts: validated READY FOR /prepare-pr, zero findings, zero proof gaps.

Known proof gaps: none.

@steipete
steipete merged commit 3be66d7 into main Aug 4, 2026
203 of 214 checks passed
@steipete
steipete deleted the codex/fix-new-session-metadata branch August 4, 2026 05:24
@steipete

steipete commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 4, 2026
* origin/main:
  fix: preserve live updater failure diagnostics (#119096)
  fix: recover new-session models through Gateway startup (#119120)
  test(qa): cover instruction profile artifacts (#119078)
  fix(telegram): record automatic delivery message ids
  test(qa): cover memory promotion safety (#119093)
  test(qa): prove overflow compaction pruning (#119033)
  fix(tool-search): preserve deferred MCP failures (#118363)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 4, 2026
)

* fix: preserve new-session models through startup errors

* fix(ui): normalize metadata retry failures to errors

* test(ui): prove new-session metadata recovery

* test(gateway): use public model fixtures

* test(ui): order auth transport E2E lifecycle

* test(ui): drain auth transport bootstrap work

---------

Co-authored-by: ZYV5ge <[email protected]>
vincentkoc added a commit that referenced this pull request Aug 4, 2026
* 'main' of https://github.com/openclaw/openclaw:
  test(qa): cover sandboxed exec behavior (#119053)
  test(qa): prove shared-channel memory recall (#119111)
  fix(telegram): keep request deadlines through response bodies
  test(qa): cover gateway plugin approvals (#119128)
  fix(ai): keep OpenAI tool call id truncation UTF-16 safe (#110471)
  fix: preserve live updater failure diagnostics (#119096)
  fix: recover new-session models through Gateway startup (#119120)
  test(qa): cover instruction profile artifacts (#119078)
  fix(telegram): record automatic delivery message ids
  test(qa): cover memory promotion safety (#119093)
  test(qa): prove overflow compaction pruning (#119033)
  fix(tool-search): preserve deferred MCP failures (#118363)
  fix(macos): keep setup activation within app checks
  test(setup): type provider kind fixture
  fix(setup): complete prepared model activation
  fix(protocol): regenerate Swift wizard models
  fix(ollama): activate the model selected during setup
  fix(setup): preserve the prepared model handoff
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 5, 2026
* origin/main:
  fix: preserve live updater failure diagnostics (openclaw#119096)
  fix: recover new-session models through Gateway startup (openclaw#119120)
  test(qa): cover instruction profile artifacts (openclaw#119078)
  fix(telegram): record automatic delivery message ids
  test(qa): cover memory promotion safety (openclaw#119093)
  test(qa): prove overflow compaction pruning (openclaw#119033)
  fix(tool-search): preserve deferred MCP failures (openclaw#118363)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 5, 2026
* 'main' of https://github.com/openclaw/openclaw:
  test(qa): cover sandboxed exec behavior (openclaw#119053)
  test(qa): prove shared-channel memory recall (openclaw#119111)
  fix(telegram): keep request deadlines through response bodies
  test(qa): cover gateway plugin approvals (openclaw#119128)
  fix(ai): keep OpenAI tool call id truncation UTF-16 safe (openclaw#110471)
  fix: preserve live updater failure diagnostics (openclaw#119096)
  fix: recover new-session models through Gateway startup (openclaw#119120)
  test(qa): cover instruction profile artifacts (openclaw#119078)
  fix(telegram): record automatic delivery message ids
  test(qa): cover memory promotion safety (openclaw#119093)
  test(qa): prove overflow compaction pruning (openclaw#119033)
  fix(tool-search): preserve deferred MCP failures (openclaw#118363)
  fix(macos): keep setup activation within app checks
  test(setup): type provider kind fixture
  fix(setup): complete prepared model activation
  fix(protocol): regenerate Swift wizard models
  fix(ollama): activate the model selected during setup
  fix(setup): preserve the prepared model handoff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui gateway Gateway runtime maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

2 participants