Repository navigation
fix(gateway): keep other agents working while agents are created or deleted - #169249
Conversation
Scope captured session routes and prepared model replacement admission to the affected agents. Preserve unchanged dispatch publications and run leases while another agent reloads. Carry superseded model preparation into the next accepted config, including neutral successors, instead of escalating agent-only reload failures to a Gateway restart. Preserve the existing sessions.create runError contract for rejected initial turns.
Prepare agent runtime databases before publishing new roster entries. Carry preserved write outcomes through applied successor configs and retain healthy runtime generations during overlapping scoped refreshes. Share receipt transfer and waiting-root drain ownership across automatic and explicit plugin reloads while preserving invoking authority.
Scope auth snapshot and deletion registry publications to their actual owners. Resolve registry discovery against newer published facts and retain model generations across unrelated deletion cleanup. Preserve live authority, selected-store fencing, and deletion draining.
Release runtime lifecycle leases through the existing worker writer queue instead of abandoning native cleanup on lock contention. Keep expected pre-open deletion refusals local to their SQLite actor so unchanged agents retain admission. Preserve partial-open retirement and exact-source lease cleanup. Cover real overlapping create/delete RPCs, visible duplicate-delete outcomes, native release contention, and unchanged-agent worker admissions. Existing terminal-reload fixtures now join full scheduler transactions before advancing to their next write.
Drive sequential reloads through their scheduler completion so asynchronous lease release cannot outlive the only fake-clock wake. Preserve intentionally blocked preflights and watcher handoffs, including their observed lease backoff and independent restart timers.
A different shared database can replace the single active registry memo without publishing any registry change. Follow the captured memo publication link before retrying so overlapping database reads cannot keep each other pending.
Merge main snapshot b5a9b9b while retaining scoped session and model admission, successor receipts, queued lease cleanup, and local deletion refusals. Preserve main's simplified runtime and registry owners and serialized config application. Keep completed active and retry applications attached to their own successful receipt; retain unfinished model preparation across valid successors and document paused recovery after rejected successors.
|
🦞👀 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. What this changesThis PR keeps unchanged agents available while other agents are created, deleted, or applied through overlapping configuration reloads. Example: Create agent research while sending hello to agent:main:demo.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-owned PR repairs a current cross-agent availability failure, resolves the prior findings, and has no remaining actionable defect identified in this review. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway agent mutations enter the configuration reload owner, which coordinates session routing, model and credential publications, registry discovery, and database lifecycle cleanup before acknowledging application. flowchart TD
A[Agent mutation RPC] --> B[Agent database preparation]
B --> C[Configuration reload owner]
C --> D[Scoped runtime publication]
C --> E[Registry and lease settlement]
F[Concurrent chat or session RPC] --> G[Current route and authorization]
G --> D
D --> H[Persisted turn and reply]
Technical reviewBest possible solution: Keep routing, publication, and storage responsibilities with their existing owners while invalidating only affected agents and settling preserved writes through successful successor reloads. Do we have a high-confidence way to reproduce the issue? Current-main routing captures the entire roster, establishing the unrelated-agent invalidation path, and the body reports concrete concurrent RPC failures; no target code was executed during this read-only review. Is this the best way to solve the issue? The repair addresses the existing routing and publication owners, preserves target-specific and live-authority checks, and resolves the earlier validation and destructive-preview defects. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8524e7f1cbe2. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (2 earlier review cycles)
Reviewed October 11, 2026, 4:36 PM ET / 20:36 UTC (Revision 3). |
Read fresh worker registry facts for destructive planning without invalidating runtime publication witnesses. Validate chat targets before capturing resolved routing so invalid input retains INVALID_REQUEST. Scope the retained-witness regression and synchronize operator model-policy reload proof with scheduler-owned lease cleanup. Preserve publication-following discovery, permission policy, and stored data.
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
Worker-backed lease release reports retired ownership during cleanup. Assert that refusal and inspect the migration outcome after settlement so the finalizer cannot mask the schema rejection or unchanged database bytes. Follows #169249. Production authority, schema, and update behavior are unchanged.
…eleted (openclaw#169249) * fix(gateway): isolate agent config reload admission Scope captured session routes and prepared model replacement admission to the affected agents. Preserve unchanged dispatch publications and run leases while another agent reloads. Carry superseded model preparation into the next accepted config, including neutral successors, instead of escalating agent-only reload failures to a Gateway restart. Preserve the existing sessions.create runError contract for rejected initial turns. * fix(gateway): settle overlapping agent config reloads Prepare agent runtime databases before publishing new roster entries. Carry preserved write outcomes through applied successor configs and retain healthy runtime generations during overlapping scoped refreshes. Share receipt transfer and waiting-root drain ownership across automatic and explicit plugin reloads while preserving invoking authority. * fix(gateway): preserve unchanged agents during roster churn Scope auth snapshot and deletion registry publications to their actual owners. Resolve registry discovery against newer published facts and retain model generations across unrelated deletion cleanup. Preserve live authority, selected-store fencing, and deletion draining. * fix(gateway): keep overlapping agent reloads moving Release runtime lifecycle leases through the existing worker writer queue instead of abandoning native cleanup on lock contention. Keep expected pre-open deletion refusals local to their SQLite actor so unchanged agents retain admission. Preserve partial-open retirement and exact-source lease cleanup. Cover real overlapping create/delete RPCs, visible duplicate-delete outcomes, native release contention, and unchanged-agent worker admissions. Existing terminal-reload fixtures now join full scheduler transactions before advancing to their next write. * test(gateway): join reload cleanup in restart fixtures Drive sequential reloads through their scheduler completion so asynchronous lease release cannot outlive the only fake-clock wake. Preserve intentionally blocked preflights and watcher handoffs, including their observed lease backoff and independent restart timers. * fix(state): retry registry reads only after publication A different shared database can replace the single active registry memo without publishing any registry change. Follow the captured memo publication link before retrying so overlapping database reads cannot keep each other pending. * fix(gateway): preserve registry previews and chat validation Read fresh worker registry facts for destructive planning without invalidating runtime publication witnesses. Validate chat targets before capturing resolved routing so invalid input retains INVALID_REQUEST. Scope the retained-witness regression and synchronize operator model-policy reload proof with scheduler-owned lease cleanup. Preserve publication-following discovery, permission policy, and stored data.
Worker-backed lease release reports retired ownership during cleanup. Assert that refusal and inspect the migration outcome after settlement so the finalizer cannot mask the schema rejection or unchanged database bytes. Follows openclaw#169249. Production authority, schema, and update behavior are unchanged.
9e90500 backported the #169249 state-lease change (cleanup releases through the worker writer queue, needed by #173225's native-cleanup test) without #169249's reload fixture adaptation. Release now settles after an awaited worker round trip, so fixtures that drove sequential reloads with one vi.advanceTimersByTimeAsync(0) wake hung for 120s. Port the b1cadee fixture changes to the terminal, restart-sequence and operator model-policy tests: drive reloads through a scheduler clock and join each wake. Apply the same join to the release-only watcher handoff test (removed on main by #168980). Assertions are unchanged. Adapted from b1cadee (#169249).
What Problem This Solves
Creating or deleting one agent disturbed every other agent on the Gateway. Each
agents.create/agents.deletewritesagents.entriesand hot-reloads config, and during that reload:sessions.createfor an unrelated existing agent failedUNAVAILABLE SessionMutationFactsUnavailableError(7/12 when racing a create; deterministic at 300-450 ms offsets), or returned ok withrunStarted:falseand the message not persisted.chat.sendinto an existing conversation of another agent failed 5/12 ("Your request couldn't be completed: SessionMutationFactsUnavailableError ...").prepared model runtime plugin generation was superseded.config change requires gateway restart (hot reload recovery: prepared model runtime reload)),agents.createreportednot confirmed (superseded)although the agent was saved, and the Gateway restarted.On main
c2e1f0f60557, two overlapping operators lost 8/20 creates, failed 7/10 sends, logged 9 restart escalations, and the resulting restart took the Gateway down (that exit is fixed separately in #169167).Why This Change Was Made
Agent roster changes invalidated state for every agent, and overlapping reloads had no owner that carried a superseded change forward. Fixed at the owners:
src/gateway/session-store-key.ts): unrelated roster changes no longer invalidate captured routes for configured agents; a route change for the requested agent still rejects.src/agents/prepared-model-runtime*.ts,src/gateway/server-reload-model-runtime-scope.ts): unchanged agents keep dispatch/run admission and their healthy plugin generations while another agent is replaced; deletion's model-neutral reference cleanup no longer forces a refresh.src/agents/auth-profiles/runtime-snapshots.ts): adding/removing one agent's store publishes that change only; shared credentials still invalidate globally.src/agents/agent-create.ts): the runtime database is initialized before the agent is published, so a reload never prepares an agent at schema 0.src/gateway/config-reload.ts,server-reload-hot.ts): a write whose change is carried by a newer, successfully applied config reports applied instead of superseded; a superseded preparation failure is recovered by the newer config instead of creating restart debt.src/state/openclaw-agent-db-registry-listing.ts): rereads only when the owner's publication advances (no blind retry); lease cleanup joins the worker queue instead of silently abandoning SQLite contention (that abandonment produced a ~300 s reload stall in an intermediate version). Deleted-agent open refusals stay local, and a duplicate delete returns the existing "not found".Deletion draining (#168199) is not changed. No schema, persistence, protocol, or permission change.
User Impact
Adding or removing an agent (Control UI, CLI, or two operators at once) no longer rejects, drops, or fails chats on other agents, and no longer restarts the Gateway.
Evidence
92bd5dedb876, fresh state, real OpenAI provider; probes raceagents.create/agents.deleteagainst session creation and messages on unchanged agents:chat.send10/10 delivered.superseded, 0 facts-unavailable, 0 stale-version; overlap finished in 102 s, max agent operation 12.8 s.docs/gateway/configuration/hot-reload.md). The growth is the scoped publication/receipt ownership above; duplicate retry logic was removed in the same owners.Exact-head CI attribution for native inherited-failure landing (2026-10-11)
Head:
2a64296a9fa0aa63fbfd6b19f5e38522062d6606. CI run 38169800311, attempt 1 completed with 96 successful jobs, 22 skipped, six failed mocked Control UI E2E shards and their downstreamopenclaw/ci-gate; zero cancelled jobs. All 64 selected Node test jobs, production type checks (core/UI/extensions), architecture cycle checks, andsecurity-fastpassed. The run remains failed; this landing uses Peter's explicitly authorized native pre-existing-failure admin exception, with security and review gates still enforced.Complete logs were fetched from each job endpoint. Every failed job checked out merge
e3c2ce090ab1cefcc5ce2cfd01f8bfd5b88b0142, with ordered parents maindf78e7a82c22d86fdd84d86cf8d48b664b3719f1and this exact PR head.git diff --name-onlyagainst merge baseb5a9b9b41c343f4a11c44dd511a49c348f63d704confirms no changes underui/,test/,scripts/,packages/, or.github/. Git object equality against the tested baseline covers complete UI assets/styles/mock fixtures, shared packages, test/CI harnesses, dependency manifests/lockfile, and relevant shared inputs.Fourteen of the fifteen failed cases also failed by exact test name on main's scheduled run 38168292109, head
4e3818bab0febf3ce265aafab07b0c98b7cf7f16:chat-subagent-waiting: child activity/parent working indicatorclaude-sessions: all three native-history pagination/anchor caseschat-follow-maintenance: contraction/growth/navigationchat-cold-load-anchor: cached tail before hellochat-history-loading; two manualchat-history-prepend-anchorvariants; dark/lightchat-position-rail;chat-scrollgeometrychat-position-rail-split: both panes' Escape ownershipShard 7's fifteenth case is
model-provider-usage-outcomes.e2e.test.ts, “keeps configured models visible when their catalog fails, then recovers on refresh.” It expectsMore models could not be discovered.but receivesModel catalog temporarily unavailableRetry. The main baseline itself is #169316: its one-line renderer change displaysprops.catalogDiscoveryErrorinstead of the generic translation. The unchanged test injects exactlyModel catalog temporarily unavailablethrough its mockedmodels.listresponse; the unchanged loader/controller pass that error to the renderer. This independently identifies the main change and stale test expectation as the cause. The earlier main run predates that UI change, so no exact-case main failure is claimed for this fifteenth case.These jobs set
OPENCLAW_UI_E2E_SKIP_REAL_GATEWAY=1; test-controlled in-pageMockWebSocketresponses drive the browser assertions. The changed server routing, auth publication, runtime refresh and database code cannot supply those responses. One harness import reaches the changed admission module only for teardown's no-optionsgetActiveGatewayRootWorkCount(), whose return is still exactly the active-root set size. None of the failures is that teardown check; the changed exclusion/reload-waiting behavior is not selected.The aggregate job reports
checks-ui-e2eas its sole failed selected lane. No CI rerun, synthetic push, or local replay was used to obtain green. The native evidence retains all six failed-job logs, main matching logs, source hashes, tested-merge provenance, and the failed result. Follow-up for the UI owners: reconcile #169316's E2E error-copy expectation and the inherited layout/history failures.