Repository navigation
fix: session patches hang while the model catalog is loading - #166376
Conversation
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.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 9:21 PM ET / October 7, 2026, 01:21 UTC. ClawSweeper reviewWhat this changesThe PR bounds model-catalog waits during single and bulk session updates, shares that policy with creation and catalog continuation, and preserves catalog-independent imports. Merge readiness✅ Ready for maintainer review This PR still provides a distinct repair: current main leaves catalog-dependent session patches unbounded. No actionable introduced defect was found. Likely related people: steipete and ericcaiwx-star are routing candidates based on prior merged work in these paths; exact source-line attribution remains unverified. Priority: P2 Review scores
Verification
How this fits togetherGateway session-control requests prepare model selections before persisting session changes. Catalog publication feeds that preparation; timeout failures return to callers while existing commit guards protect durable session state. flowchart TD
A[Session control request] --> B[Prepare session changes]
B --> C{Catalog required?}
C -->|Yes| D[Bounded catalog observation]
D -->|Ready| E[Revalidate and commit]
D -->|Timeout or cancellation| F[Retryable unavailable outcome]
C -->|No| E
E --> G[Ordered request outcomes]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -6, Tests +130, Docs +2. Total +126 across 11 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep one request-owned catalog deadline while preserving independent bulk outcomes, catalog-independent imports, and live commit-time authorization. Do we have a high-confidence way to reproduce the issue? Yes, source establishes a clear path: a catalog-dependent patch awaits the unbounded loader on current main. The captured negative controls corroborate it; this review did not execute a reproduction. Is this the best way to solve the issue? Yes, sharing the existing request-owned deadline is a focused repair that leaves catalog publication, durable writes, and authorization with their existing owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 98567acd6060. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
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.
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)
What Problem This Solves
Session updates and bulk updates can hang indefinitely while model-catalog publication is stalled.
Fixes #161409.
Follow-up to #165989 and #166089.
User Impact
Catalog-dependent
sessions.patchandsessions.patchManyoperations now return retryableUNAVAILABLEafter their shared 20-second catalog budget expires, or when their request, connection, or available captured authority is canceled. A rejected target remains unchanged, including after late catalog publication, and can be retried. Bulk updates retain ordered per-target outcomes and independent successful targets.Why This Change Was Made
One shared helper now owns the monotonic catalog deadline and cancellation policy for patch, bulk patch, creation, and Gateway catalog continuation. It derives the budget from two-thirds of
DEFAULT_GATEWAY_REQUEST_TIMEOUT_MS, retains response headroom, and prevents a later read from starting after the budget expires. Existing commit guards and creation idempotency remain in their owners.Source tracing also established that
sessions.catalog.importnever calls its supplied model-catalog loader: it passes none of the selection or fork options that consume it. This removes that unused callback and proves that import and re-import still succeed with a never-publishing catalog, preserving existing selection and transcript deduplication. Import therefore has preservation coverage, not a fabricated failing timeout regression; it already succeeds on main.Production LOC: +85 / -91 = -6; tests +130 / -0; docs +2 / -0. No configuration, protocol, SDK, schema, or changelog changes.
Evidence
Pinned base:
7880834c19616b5efb871e1755cd4b30cf2f2481.Reviewed head:
0bd1de9ae5f88e1f2bfbb9c8d2f860d062307fee.The final new handler tests were run with only production reverted to that main commit, then with candidate production restored. Negative control: 2 failed, 1 passed, 83.89 seconds wall. Both patch tests accepted and committed the late catalog result on main; import correctly passed on main.
An earlier baseline probe also confirmed that neither patch handler had responded at 20 seconds of fake time. Candidate assertions await the actual handler outcome after releasing the late catalog result, then check unchanged persisted entries and a successful retry. No real sleeps, polling, or per-test Gateway boots were added.
Validation uses
node scripts/run-vitest.mjs <explicit files> --maxWorkers=1:sessions-mutations.catalog-queue.test.tssession-catalog-import.integration.test.tssession-model-catalog-wait.test.tsserver.sessions.create.catalog-wait.test.tssession-catalog-gateway-copy.test.tsTest cost: the full patch/import invocation took 157.78 seconds wall, including cold worker compilation/imports. Its two new patch cases took 4.048 s / 1.603 s. The existing patch suite exceeds the 30-second file budget because it proves real database-writer release, alias/identity revalidation, cross-store commits, and authority behavior; this change adds two cases to that existing owner fixture. The helper and unchanged create/continue cases passed in the earlier four-file invocation (128.89 seconds wall); its two new patch assertions initially ran before database-worker completion, were corrected, and passed in the final full patch/import run above. There are 49 distinct passing cases across the final evidence. CI is attached to the reviewed head and is in progress; final CI seconds are pending completion. The earlier draft run was skipped.
pnpm tsgo:core: passed.pnpm tsgo:core:test --ci-graphs-json '["core-test-gateway-methods","core-test-gateway-server"]': passed.config/tsconfig/oxlint.core.json, oxfmt, andgit diff --check: passed.This is direct Gateway-handler and durable-state proof, not a live Gateway transport run. Existing create/continue regressions are unchanged. Catalog-worker performance and other model-runtime waits remain outside this change.