Skip to content

fix: catalog continuation hangs while models are loading - #166089

Merged
obviyus merged 5 commits into
openclaw:mainfrom
ericcaiwx-star:codex/fix-166084-catalog-continue-wait
Oct 6, 2026
Merged

obviyus merged 5 commits into
openclaw:mainfrom
ericcaiwx-star:codex/fix-166084-catalog-continue-wait

Conversation

@ericcaiwx-star

@ericcaiwx-star ericcaiwx-star commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #166084

What Problem This Solves

Continuing a catalog snapshot into a Gateway session could wait indefinitely while model-catalog publication was still pending. The copy path observed the catalog twice: once while assessing the source model and again during atomic session creation.

User Impact

Catalog continuation now settles within the existing Gateway request budget instead of hanging. A deadline, request cancellation, or connection closure returns retryable UNAVAILABLE; the operator can retry without a partial session, imported history, or adoption event.

Why This Change Was Made

  • Uses one lazy monotonic 20-second budget across both catalog observations, matching the existing sessions.create policy while leaving response headroom.
  • Threads the in-process request signal through the public continuation handler and combines it with the client connection signal.
  • Preserves configured-model fallback for ordinary availability-assessment errors; only the owned timeout/cancellation sentinel bypasses fallback.
  • Keeps atomicInitialization, authorization, commit guards, and catalog/history ownership unchanged.

No protocol, schema, configuration, catalog-worker, import, patch, or cross-agent ownership change is included.

Evidence

Exact base: 08229175e9b5d9133a6739d360a4fa1269ef3a2c

Exact head: ba6ebd82fa53e302e1dcd785c805916dd8e10f66

Pre-fix negative control on the exact base:

node scripts/run-vitest.mjs src/gateway/server-methods/session-catalog-gateway-copy.test.ts --maxWorkers=1
3 failed | 6 passed
- deadline remained pending
- shared second-read deadline remained pending
- connection cancellation remained pending

Exact-head focused proof:

node scripts/run-vitest.mjs src/gateway/server-methods/session-catalog-gateway-copy.test.ts --maxWorkers=1
Test Files  1 passed (1)
Tests       11 passed (11)
Duration    9.97s
Harness     12.96s

The focused proof covers the first wait, one monotonic budget across both waits despite a wall-clock jump, request and connection cancellation, no import/adoption after failure, ordinary fallback, and a successful clean retry.

Public-handler durable-behavior proof:

node scripts/run-vitest.mjs run src/gateway/server-methods/session-catalog-import.integration.test.ts
Test Files  1 passed (1)
Tests       11 passed (11)
Duration    29.42s
Harness     32.81s

The added sessions.catalog.continue case invokes the public handler with a stalled real prepared-catalog owner, cancels the request, receives retryable UNAVAILABLE, and verifies that the SQLite session-key set is unchanged and provider history was not read. It then retries through the same public handler and verifies the real durable session entry, imported external-content transcript, and adopted state event. It does not mock session creation, SQLite persistence, transcript import, or adoption recording. The case itself ran in 404ms on the final combined run.

Exact-head real transport proof:

pnpm exec vitest --config test/vitest/vitest.gateway-server.config.ts run \
  src/gateway/server.catalog-continue.transport-proof.test.ts --maxWorkers=1
Test Files  1 passed (1)
Tests       1 passed (1)
Case        38.249s
Duration    50.55s

This one-shot proof started a real Gateway and connected a real GatewayClient over loopback WebSocket. It held the real prepared-model replacement owner, sent sessions.catalog.continue, waited until the server entered that owner, disconnected the client, and awaited Gateway close/drain before releasing the owner. At that completion gate, the non-dashboard SQLite session-key set was unchanged and provider history reads remained zero. A second Gateway and client then retried successfully; public sessions.list and chat.history returned the durable copied session and wrapped external-content transcript. The temporary proof file was removed after the run and is not part of the patch.

Both review-reported polling sites now use owned completion gates: the integration test awaits entry into the prepared-catalog reader, and the request/connection tests attach their settlement assertion before abort and await it directly. No real-time polling remains in the changed tests.

Broader continuation-handler regression:

node scripts/run-vitest.mjs src/gateway/server-methods/session-catalog-gateway-copy.test.ts src/gateway/server-methods/session-catalog.test.ts --maxWorkers=1
Test Files  2 passed (2)
Tests       40 passed (40)

Atomic rollback and retry-owner proof:

node scripts/run-vitest.mjs src/gateway/server-methods/session-catalog-gateway-copy.test.ts src/gateway/session-create-atomic-initialization.test.ts src/gateway/server.sessions.create.catalog-wait.test.ts --maxWorkers=1
Test Files  3 passed (3)
Tests       22 passed (22)

Combined exact-head regression across the changed continuation owner, public handler, durable import harness, atomic initialization, and sessions.create catalog wait:

Test Files  5 passed (5)
Tests       62 passed (62)
Duration    60.18s
Harness     64.12s

Changed-file gates:

OPENCLAW_CHECK_CHANGED_SKIP_DEADCODE=1 node scripts/check-changed.mjs --base upstream/main -- src/gateway/server-methods/session-catalog-gateway-copy.ts src/gateway/server-methods/session-catalog-gateway-copy.test.ts src/gateway/server-methods/session-catalog-continue.ts src/gateway/server-methods/session-catalog.ts src/gateway/server-methods/session-catalog-import.integration.test.ts
exit 0

The unskipped run passed all patch-related format, lint, ratchet, boundary, production typecheck, and core-test typecheck gates. Its only failure was the full-tree Knip baseline for extensions/voice-call/src/types.ts: CallBrief; that untouched export is present identically on exact-base upstream/main.

GitHub CI for the exact head passed: all 36 executed jobs succeeded, checks-node-changed completed in 4m28s (268s), and pr-fail-fast completed successfully.

Maintainer runtime validation

Validated unchanged head ba6ebd82fa53e302e1dcd785c805916dd8e10f66 in an isolated Node 24.16.0 Docker Gateway, using a configured local session-catalog/provider fixture. Its copy result supplies preferredModel; a held asynchronous provider discovery during config reload keeps the real model-runtime publication owner pending. Requests use authenticated loopback WebSocket RPC, not direct handler invocation.

  • Production revert baseline (the three production files from 08229175e9b5d9133a6739d360a4fa1269ef3a2c, unchanged on current main bff90d69144ceec82e75f92d59c3a29ec7876351): sessions.catalog.continue remained pending at the 60-second observation cap.
  • Candidate: returned retryable UNAVAILABLE after 20.040 seconds, with the catalog-still-loading message.
  • Disconnect control: closing the requester after two seconds produced server-side UNAVAILABLE at 2.061 seconds. Session/transcript table counts were unchanged and no provider history read occurred.
  • Healthy control: releasing publication allowed continuation in 580 ms. Public sessions.list reported the requested catalog-proof/preferred model with a user model override.
  • Regression negative control: bounds preferred-model assessment before creating a Gateway session failed on the production revert baseline because the result was still pending. On the candidate, all 11 tests in session-catalog-gateway-copy.test.ts passed; wrapper wall time 23.16 seconds (--maxWorkers=1).
  • Live gate: one real openai/gpt-5-mini run through the candidate Gateway completed with status: ok, thinkingLevel: low, configured output budget 4096, and 625 output tokens. The first-run onboarding response took precedence over the requested marker; this verifies successful live inference, not exact prompt adherence.

No overlap with Pash/Sarah changes. Credit remains with ericcaiwx-star for the fix and regression coverage. No additional source changes were necessary. The stale-base check found no main drift on the five changed files.

@clawsweeper

clawsweeper Bot commented Oct 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.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 6, 2026
@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 9:43 AM ET / 13:43 UTC (Revision 7).

ClawSweeper review

What this changes

The PR bounds model-loading waits during catalog-to-Gateway session copies, propagates request cancellation, and adds deadline, cancellation, fallback, and durable retry coverage.

Merge readiness

✅ Ready for maintainer review

This PR remains necessary: current main and the latest release retain the reported unbounded waits. The prior review’s timing request is satisfied, the supplied production-path proof is sufficient, and no actionable patch defect remains.

Priority: P2
Reviewed head: ba6ebd82fa53e302e1dcd785c805916dd8e10f66

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with sufficient real transport recovery proof and no remaining actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The exact-head real Gateway/GatewayClient run exercises the changed catalog-copy owner under stalled publication, observes no durable artifacts after disconnect and drain, and verifies successful durable retry through public RPCs. Handler and fake-clock regressions supplement this evidence; no stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The exact-head real Gateway/GatewayClient run exercises the changed catalog-copy owner under stalled publication, observes no durable artifacts after disconnect and drain, and verifies successful durable retry through public RPCs. Handler and fake-clock regressions supplement this evidence; no stored-data contract changes.
Evidence reviewed 8 items Pinned production change: The introduced diff wraps both catalog observations in one lazy monotonic budget, combines request and connection cancellation, and preserves ordinary availability-error fallback through an identity-specific cancellation sentinel.
Current main still needs this fix: Fetched main directly awaits preferred-model assessment and passes an unbounded catalog loader into session creation. The merged sibling fix #165989 explicitly leaves catalog continuation as follow-up work.
Latest-release check: The v2026.9.8 source likewise contains the direct assessment await and direct create-time catalog loader; the requested continuation fix is not already shipped there.
Findings None None.
Security None None.

How this fits together

Session catalog continuation copies a plugin-provided conversation snapshot into a new Gateway session. Model availability checks precede atomic session creation, transcript import, and adoption recording.

flowchart TD
  A[Continue catalog snapshot] --> B[Authorize source and creation]
  B --> C[Get provider snapshot]
  C --> D[Observe model catalog]
  E[Shared deadline and cancellation] --> D
  D --> F[Atomic session and history import]
  D --> G[Retryable unavailable response]
  F --> H[Record adoption and return session]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +84, Tests +263. Total +347 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 97 13 +84
Tests 2 309 46 +263
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 406 59 +347

Review metrics

Metric Value Why it matters
Production versus regression coverage production net +84 lines; tests net +263 lines Production growth is explained by shared wait ownership, cancellation, and error conversion; added coverage checks deadline behavior and durable recovery.

Technical review

Best possible solution:

Keep catalog publication under its existing owner while request-owned observations settle promptly and failed copies leave no durable artifacts.

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

Yes: current-main source exposes two unbounded catalog observations, and the supplied negative control reports pending deadline and cancellation cases. This read-only review did not execute a reproduction.

Is this the best way to solve the issue?

Yes: bounding the two request-owned observations preserves shared publication, ordinary fallback, atomic initialization, and existing authorization guards.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1a5524f70f5c.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This fixes a concrete hang in the bounded catalog-continuation workflow without changing configuration or broader session behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The exact-head real Gateway/GatewayClient run exercises the changed catalog-copy owner under stalled publication, observes no durable artifacts after disconnect and drain, and verifies successful durable retry through public RPCs. Handler and fake-clock regressions supplement this evidence; no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The exact-head real Gateway/GatewayClient run exercises the changed catalog-copy owner under stalled publication, observes no durable artifacts after disconnect and drain, and verifies successful durable retry through public RPCs. Handler and fake-clock regressions supplement this evidence; no stored-data contract changes.

Evidence

What I checked:

  • Pinned production change: The introduced diff wraps both catalog observations in one lazy monotonic budget, combines request and connection cancellation, and preserves ordinary availability-error fallback through an identity-specific cancellation sentinel. (src/gateway/server-methods/session-catalog-gateway-copy.ts:35, ba6ebd82fa53)
  • Current main still needs this fix: Fetched main directly awaits preferred-model assessment and passes an unbounded catalog loader into session creation. The merged sibling fix fix: New Session hangs while the model catalog is loading #165989 explicitly leaves catalog continuation as follow-up work. (src/gateway/server-methods/session-catalog-gateway-copy.ts:43, 1a5524f70f5c)
  • Latest-release check: The v2026.9.8 source likewise contains the direct assessment await and direct create-time catalog loader; the requested continuation fix is not already shipped there. (src/gateway/server-methods/session-catalog-gateway-copy.ts:43, fc23bc864e45)
  • Real transport recovery proof: The captured PR body reports an exact-head run using a real Gateway and GatewayClient over loopback WebSocket. With the prepared-model owner held, client disconnect followed by Gateway drain left session keys unchanged and history reads at zero; a subsequent real-client retry exposed the durable copied session through sessions.list and chat.history. Reported case time: 38.249 seconds. This reviewer did not execute contributor code. (ba6ebd82fa53)
  • Durable handler regression: The added public-handler case awaits catalog-reader entry, aborts the request, checks retryable UNAVAILABLE and unchanged SQLite session keys, then verifies a successful retry with imported untrusted transcript content and an adoption event. Existing creation, persistence, transcript, and adoption owners remain in use. (src/gateway/server-methods/session-catalog-import.integration.test.ts:445, ba6ebd82fa53)
  • Re-review requests resolved: The current captured body supplies the previously requested standalone Gateway-copy suite timing: 9.97 seconds Vitest duration and 12.96 seconds harness wall time. It also supplies integration timing and 268 CI seconds for checks-node-changed. Current tests replace the earlier polling sites with completion gates and direct settlement assertions. (src/gateway/server-methods/session-catalog-gateway-copy.test.ts:298, ba6ebd82fa53)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • fuller-stack-dev: 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 (6 earlier review cycles)
  • reviewed 2026-10-06T11:05:30.320Z sha 654aa62e7855848aaa8e522b30d82424280b079f :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-06T11:14:28.078Z sha f8009f079df0e0fb6b888ad28d6fc6a0d597c7b3 :: needs real behavior proof before merge. :: [P2] Implement the bounded waits before adding passing timeout expectations
  • reviewed 2026-10-06T11:53:28.499Z sha 3186225481c750e3a60a8573886b6b04d5e3a31c :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-06T12:27:54.505Z sha ed73f1735346bb1536e38ad8b1e6e8d2562bf038 :: needs real behavior proof before merge. :: [P3] [P3] Replace the catalog-read polling with a completion gate
  • reviewed 2026-10-06T12:43:46.734Z sha ed73f1735346bb1536e38ad8b1e6e8d2562bf038 :: needs real behavior proof before merge. :: [P3] [P3] Replace the catalog-read polling with a completion gate | [P3] [P3] Await cancellation settlement without real-time polling
  • reviewed 2026-10-06T13:33:03.190Z sha ba6ebd8 :: needs changes before merge. :: none

@ericcaiwx-star

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Oct 6, 2026
@ericcaiwx-star
ericcaiwx-star force-pushed the codex/fix-166084-catalog-continue-wait branch from ed73f17 to ba6ebd8 Compare October 6, 2026 13:16
@ericcaiwx-star

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 6, 2026
@ericcaiwx-star

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus
obviyus merged commit 05838d8 into openclaw:main Oct 6, 2026
150 checks passed
@obviyus

obviyus commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Landed as 05838d8. Thanks @ericcaiwx-star!

steipete added a commit that referenced this pull request Oct 7, 2026
Share the monotonic catalog deadline across creation, continuation, and session patch handlers. Return retryable UNAVAILABLE for affected targets without a late commit, retaining ordered bulk outcomes and live commit guards. Remove the unused import loader and preserve catalog-independent import and re-import.

Follow-up to #165989 and #166089.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 7, 2026
…6089)

After openclaw#165989 bounded model-catalog waits in `sessions.create`, the Gateway-copy branch of `sessions.catalog.continue` still had two request-owned catalog reads with no deadline or cancellation: the preferred-model availability check and the create-time catalog loader. With catalog publication stalled, continuing a catalog thread into a Gateway session could hang past the 20 s create policy and past the requester's connection. Both reads now follow the same bounded, cancellable policy.

Proof: a built Gateway with a local provider whose catalog publication stalls. Base was still pending at 60 s; this change returns a retryable UNAVAILABLE at 20.0 s. A requester disconnect settles the server side in about 2 s with no session or transcript written. A healthy continuation still succeeds and keeps the preferred model. The regression test fails on base and passes here.

Fixes openclaw#166084.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 7, 2026
Share the monotonic catalog deadline across creation, continuation, and session patch handlers. Return retryable UNAVAILABLE for affected targets without a late commit, retaining ordered bulk outcomes and live commit guards. Remove the unused import loader and preserve catalog-independent import and re-import.

Follow-up to openclaw#165989 and openclaw#166089.
RomneyDa pushed a commit that referenced this pull request Oct 11, 2026
After #165989 bounded model-catalog waits in `sessions.create`, the Gateway-copy branch of `sessions.catalog.continue` still had two request-owned catalog reads with no deadline or cancellation: the preferred-model availability check and the create-time catalog loader. With catalog publication stalled, continuing a catalog thread into a Gateway session could hang past the 20 s create policy and past the requester's connection. Both reads now follow the same bounded, cancellable policy.

Proof: a built Gateway with a local provider whose catalog publication stalls. Base was still pending at 60 s; this change returns a retryable UNAVAILABLE at 20.0 s. A requester disconnect settles the server side in about 2 s with no session or transcript written. A healthy continuation still succeeds and keeps the preferred model. The regression test fails on base and passes here.

Fixes #166084.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 05838d8)
RomneyDa pushed a commit that referenced this pull request Oct 11, 2026
Share the monotonic catalog deadline across creation, continuation, and session patch handlers. Return retryable UNAVAILABLE for affected targets without a late commit, retaining ordered bulk outcomes and live commit guards. Remove the unused import loader and preserve catalog-independent import and re-import.

Follow-up to #165989 and #166089.

(cherry picked from commit c3c55ea)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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.

[Bug]: sessions.catalog.continue Gateway copies can wait indefinitely on model catalog publication

2 participants