Repository navigation
fix(memory): memory files stop indexing after plugin reloads until the next search - #167756
Conversation
Close all instance-owned memory managers through admitted lifecycle disposal, including generic registry and cache retirement. Start configured indexes through the Gateway service lifecycle so a replacement observes file changes before the next search or turn; restart the service for agent and memory-search configuration changes. Regression proof covers retired watch cancellation, successor index publication, service stop/start, and foreign memory-slot isolation. Existing background reload tests retain request-context and instance-admission coverage.
Stop retained memory services before retiring provider registrations and lazy capability caches. Carry stopped services through candidate preparation, then await startup after registry adoption and memory admission recovery, including rollback. Regression coverage proves watcher cancellation, current-provider indexing without a search or turn, joined startup, repeated reloads, separate provider registries, and recovery. Preserve the instance-owned background runner and existing SDK contracts.
|
🦞👀 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 changesMemory Core, OpenClaw’s built-in memory plugin, retires old file watchers and restarts indexing after plugin reloads and failed-reload recovery. Example: The user writes a memory file after two plugins.load reloads.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR addresses a concrete indexing failure that remains on current main. No actionable patch defect was found, and the earlier merged lifecycle repair does not cover its disposal and restart work. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherMemory Core reads agent memory files and stores searchable content in SQLite. The Gateway owns plugin replacement, service shutdown, publication, and recovery. flowchart TD
A[Plugin reload] --> B[Gateway reload lifecycle]
B --> C[Drain managers and stop memory services]
C --> D{Replacement succeeds?}
D -->|Yes| E[Publish current plugins]
D -->|No| F[Restore previous plugins]
E --> G[Resume memory admission and indexing services]
F --> G
G --> H[File changes update searchable SQLite index]
Technical reviewBest possible solution: Keep watcher retirement and joined service restart in the existing memory and Gateway lifecycle owners. Do we have a high-confidence way to reproduce the issue? Yes: the recorded live comparison exercises two plugin reloads followed by a memory-file write, and current-main source lacks the disposal and proactive restart paths. No runtime reproduction was executed in this read-only review. Is this the best way to solve the issue? Yes for the reload defect: full instance disposal and joined service handoff repair the existing owners without another SDK contract or configuration option. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9490c112abba. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +122, Tests +449, Docs +11. Total +582 across 12 files. Added test files: 0. View PR surface stats
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 (1 earlier review cycle)
Reviewed October 9, 2026, 6:03 AM ET / 10:03 UTC (Revision 2). |
Resume and restart the previous memory owners whose managers were drained even when the candidate replaces Memory Core. Join service stop and startup before reporting restoration; leave undrained services running and preserve failed recovery status when startup rejects. Cover retained and replaced runtimes at the pre-drain, post-drain checkpoint, and failed-restart boundaries with real manager watcher indexing. Preserve instance-owned background context and the existing SDK surface.
|
@clawsweeper approve Maintainer decision (coordinator for Peter, 2026-10-09): bug fix completing #167679 for watcher retirement and provider-only reloads via existing Gateway service lifecycle; no SDK change. Please complete the review of current head |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
Merged via squash.
|
…e next search (openclaw#167756) * fix(memory): retire watchers with their plugin instance Close all instance-owned memory managers through admitted lifecycle disposal, including generic registry and cache retirement. Start configured indexes through the Gateway service lifecycle so a replacement observes file changes before the next search or turn; restart the service for agent and memory-search configuration changes. Regression proof covers retired watch cancellation, successor index publication, service stop/start, and foreign memory-slot isolation. Existing background reload tests retain request-context and instance-admission coverage. * fix(memory): restart retained indexes after provider reload Stop retained memory services before retiring provider registrations and lazy capability caches. Carry stopped services through candidate preparation, then await startup after registry adoption and memory admission recovery, including rollback. Regression coverage proves watcher cancellation, current-provider indexing without a search or turn, joined startup, repeated reloads, separate provider registries, and recovery. Preserve the instance-owned background runner and existing SDK contracts. * fix(memory): restart drained owners on early reload rollback Resume and restart the previous memory owners whose managers were drained even when the candidate replaces Memory Core. Join service stop and startup before reporting restoration; leave undrained services running and preserve failed recovery status when startup rejects. Cover retained and replaced runtimes at the pre-drain, post-drain checkpoint, and failed-restart boundaries with real manager watcher indexing. Preserve instance-owned background context and the existing SDK surface.
…from opening every memory index (#174718) * perf(agents): bound catalog worker young-generation heap Keep the catalog worker's existing 512 MiB old-generation allowance while bounding its young generation to 32 MiB. Forward-port of the release/2026.10.4 fix; main moved the catalog pool into prepared-model-catalog-worker.pool.ts, so the limit now lives on that pool's single resource-limit object. (cherry picked from commit a3510e8) * fix(memory): keep cold Gateway start from opening every agent's index #167756 started Memory Core's index service eagerly on every Gateway start, opening each configured agent's memory manager right after readiness. On an idle Gateway that startup catch-up touches every session-transcript read lane, so each lane spawns its own worker isolate (plus a memory-search worker): the 2026.10.5 Gateway startup peak RSS rose from ~1.1 GB to ~1.8 GB. Cold start is demand-driven again, as before #167756: the first search, flush, or turn that needs an agent's index opens it. Once a watched manager has run in the process (a process-wide fact that survives plugin instance replacement and resets with a Gateway restart), every later service start reopens all configured indexes, so plugin reloads, provider-only reloads, rollback recovery, and memory/agent config restarts still resume watching without a search or turn. * perf(sqlite): bound broker and transcript worker young-generation heaps Cap the SQLite broker carriers and session-transcript reader workers at a 32 MiB young generation, matching the catalog worker bound, while keeping the existing 512 MiB old-generation allowance. Worker counts, lanes, admission, and lifecycle custody are unchanged. V8's default nursery grows to ~63 MiB per worker after a startup allocation burst and stays resident on idle workers. On the 2026.10.5 Gateway (fresh state, forced 16 CPUs) the broker's heap total at startup peak fell 125 -> 91 MiB and the transcript reader 81 -> 34-66 MiB; with the Memory Core cold-start fix, max Gateway peak RSS over the runs fell 1152 -> 1117 MB. Tradeoff: more frequent scavenges during large allocation bursts in these workers.
…from opening every memory index (#174718) * perf(agents): bound catalog worker young-generation heap Keep the catalog worker's existing 512 MiB old-generation allowance while bounding its young generation to 32 MiB. Forward-port of the release/2026.10.4 fix; main moved the catalog pool into prepared-model-catalog-worker.pool.ts, so the limit now lives on that pool's single resource-limit object. (cherry picked from commit a3510e8) * fix(memory): keep cold Gateway start from opening every agent's index opening each configured agent's memory manager right after readiness. On an idle Gateway that startup catch-up touches every session-transcript read lane, so each lane spawns its own worker isolate (plus a memory-search worker): the 2026.10.5 Gateway startup peak RSS rose from ~1.1 GB to ~1.8 GB. Cold start is demand-driven again, as before #167756: the first search, flush, or turn that needs an agent's index opens it. Once a watched manager has run in the process (a process-wide fact that survives plugin instance replacement and resets with a Gateway restart), every later service start reopens all configured indexes, so plugin reloads, provider-only reloads, rollback recovery, and memory/agent config restarts still resume watching without a search or turn. * perf(sqlite): bound broker and transcript worker young-generation heaps Cap the SQLite broker carriers and session-transcript reader workers at a 32 MiB young generation, matching the catalog worker bound, while keeping the existing 512 MiB old-generation allowance. Worker counts, lanes, admission, and lifecycle custody are unchanged. V8's default nursery grows to ~63 MiB per worker after a startup allocation burst and stays resident on idle workers. On the 2026.10.5 Gateway (fresh state, forced 16 CPUs) the broker's heap total at startup peak fell 125 -> 91 MiB and the transcript reader 81 -> 34-66 MiB; with the Memory Core cold-start fix, max Gateway peak RSS over the runs fell 1152 -> 1117 MB. Tradeoff: more frequent scavenges during large allocation bursts in these workers. (cherry picked from commit 6c050f8)
…from opening every memory index (openclaw#174718) * perf(agents): bound catalog worker young-generation heap Keep the catalog worker's existing 512 MiB old-generation allowance while bounding its young generation to 32 MiB. Forward-port of the release/2026.10.4 fix; main moved the catalog pool into prepared-model-catalog-worker.pool.ts, so the limit now lives on that pool's single resource-limit object. (cherry picked from commit a3510e8) * fix(memory): keep cold Gateway start from opening every agent's index openclaw#167756 started Memory Core's index service eagerly on every Gateway start, opening each configured agent's memory manager right after readiness. On an idle Gateway that startup catch-up touches every session-transcript read lane, so each lane spawns its own worker isolate (plus a memory-search worker): the 2026.10.5 Gateway startup peak RSS rose from ~1.1 GB to ~1.8 GB. Cold start is demand-driven again, as before openclaw#167756: the first search, flush, or turn that needs an agent's index opens it. Once a watched manager has run in the process (a process-wide fact that survives plugin instance replacement and resets with a Gateway restart), every later service start reopens all configured indexes, so plugin reloads, provider-only reloads, rollback recovery, and memory/agent config restarts still resume watching without a search or turn. * perf(sqlite): bound broker and transcript worker young-generation heaps Cap the SQLite broker carriers and session-transcript reader workers at a 32 MiB young generation, matching the catalog worker bound, while keeping the existing 512 MiB old-generation allowance. Worker counts, lanes, admission, and lifecycle custody are unchanged. V8's default nursery grows to ~63 MiB per worker after a startup allocation burst and stays resident on idle workers. On the 2026.10.5 Gateway (fresh state, forced 16 CPUs) the broker's heap total at startup peak fell 125 -> 91 MiB and the transcript reader 81 -> 34-66 MiB; with the Memory Core cold-start fix, max Gateway peak RSS over the runs fell 1152 -> 1117 MB. Tradeoff: more frequent scavenges during large allocation bursts in these workers.
…78169) * fix: distinguish workflow approval and exception capabilities (#172661) (cherry picked from commit aade2f8) Co-authored-by: RomneyDa <[email protected]> * fix(release): expose Linux builder admission and retain failed bundles (#170297) * fix(release): expose Linux builder admission and retain failed bundles * fix(release): preserve unconfirmed Linux dispatch status * fix(ci): make Linux build event admission explicit * fix(ci): separate Linux mirror dispatch from release builds * fix(ci): budget cold Linux source package builds (cherry picked from commit 614f559) Co-authored-by: RomneyDa <[email protected]> * fix(ui): let locale refresh workers bootstrap new locale memory (#172689) (cherry picked from commit 17bea1c) Co-authored-by: RomneyDa <[email protected]> * test(gateway): prewarm history worker before composed SDK request budgets (#172745) (cherry picked from commit 2051055) Co-authored-by: RomneyDa <[email protected]> * fix(android): prepare focused proof before running Gradle (#172668) * fix(android): prepare focused proof before running Gradle * test(android): reach proof prerequisites on Linux ARM * test: remove duplicated Android job structure assertion * fix: seed stored inference account for Docker cron cleanup (cherry picked from commit 404b708) Co-authored-by: RomneyDa <[email protected]> * fix: preserve bound Codex history after app-server restart (#172705) (cherry picked from commit 9fe4372) Co-authored-by: RomneyDa <[email protected]> * fix(release): Linux channel promotion fails after a withdrawn Windows companion (#173615) (cherry picked from commit c58afa2) Co-authored-by: RomneyDa <[email protected]> * ci(release): temporarily disable Windows companion publication (#173656) (cherry picked from commit 99ce3ea) Co-authored-by: RomneyDa <[email protected]> * fix(qa): Telegram live lane fails scenarios when the stale-update drain hits a transient Bot API error (#173465) * fix(qa): retry Telegram stale-update drain through transient Bot API failures * fix(qa): cancel Telegram drain waits on proxy stop and cap attempts by budget * test(qa): prove the Telegram drain abandons a stalled attempt at its deadline * test(qa): drop timing-dependent upstream count from Telegram drain deadline test (cherry picked from commit 387ebd6) Co-authored-by: RomneyDa <[email protected]> * fix(release): validate shipped release provenance markers against main (#173781) (cherry picked from commit eee5b40) Co-authored-by: RomneyDa <[email protected]> * fix(sqlite): settle peer closes after shared worker refusal (#173813) A refused opener stops its shared worker, so queued peer closes receive the slot's existing operation failure without running. Join native exit without recording that exact failed-slot error as a second cleanup failure. Distinct close, termination and lease-cleanup failures still propagate. Update and Doctor teardown can finish retiring peer agent stores after another opening is revoked. The rejected opening retains its error, exact lease cleanup remains owned, and uncertified native exit cannot publish a clean-close seal. The real-worker regression fails on main with native retirement failed and passes with all peer leases removed. The original intermittent sessions-tail case passed six pre-fix replays; the forced owner boundary proves this repair. Proof: sessions-tail/creation-owner/cleanup 62 passed; broker/client/reply, close-wedge and retention siblings 54 passed; final integrity owner 27 passed, one existing Linux-only skip. pnpm test src/state/openclaw-agent-execution.integrity.test.ts --maxWorkers=1: 76.57s wall, 26.00s Vitest, new regression 2.66s. Scoped types, lint, formatting, line-cap and independent P2 reviews pass. PR CI supplies broad proof. (cherry picked from commit 6d51bb2) Co-authored-by: RomneyDa <[email protected]> * fix(gateway): restore 2026.10.4 startup memory by keeping cold start from opening every memory index (#174718) * perf(agents): bound catalog worker young-generation heap Keep the catalog worker's existing 512 MiB old-generation allowance while bounding its young generation to 32 MiB. Forward-port of the release/2026.10.4 fix; main moved the catalog pool into prepared-model-catalog-worker.pool.ts, so the limit now lives on that pool's single resource-limit object. (cherry picked from commit a3510e8) * fix(memory): keep cold Gateway start from opening every agent's index #167756 started Memory Core's index service eagerly on every Gateway start, opening each configured agent's memory manager right after readiness. On an idle Gateway that startup catch-up touches every session-transcript read lane, so each lane spawns its own worker isolate (plus a memory-search worker): the 2026.10.5 Gateway startup peak RSS rose from ~1.1 GB to ~1.8 GB. Cold start is demand-driven again, as before #167756: the first search, flush, or turn that needs an agent's index opens it. Once a watched manager has run in the process (a process-wide fact that survives plugin instance replacement and resets with a Gateway restart), every later service start reopens all configured indexes, so plugin reloads, provider-only reloads, rollback recovery, and memory/agent config restarts still resume watching without a search or turn. * perf(sqlite): bound broker and transcript worker young-generation heaps Cap the SQLite broker carriers and session-transcript reader workers at a 32 MiB young generation, matching the catalog worker bound, while keeping the existing 512 MiB old-generation allowance. Worker counts, lanes, admission, and lifecycle custody are unchanged. V8's default nursery grows to ~63 MiB per worker after a startup allocation burst and stays resident on idle workers. On the 2026.10.5 Gateway (fresh state, forced 16 CPUs) the broker's heap total at startup peak fell 125 -> 91 MiB and the transcript reader 81 -> 34-66 MiB; with the Memory Core cold-start fix, max Gateway peak RSS over the runs fell 1152 -> 1117 MB. Tradeoff: more frequent scavenges during large allocation bursts in these workers. (cherry picked from commit 6c050f8) Co-authored-by: RomneyDa <[email protected]> * fix(ui): start a fresh model catalog read after invalidation (#174812) (cherry picked from commit 919e835) Co-authored-by: RomneyDa <[email protected]> --------- Co-authored-by: RomneyDa <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Fixes: after a hot plugin reload (for example editing
plugins.load), Memory Core stops indexing memory files until something wakes it, and a retired file watcher keeps failing on every change:Seen on a dev Gateway on current main (after #167679): the retired Memory Core instance's watcher stayed alive and failed on every memory-file change; a new memory note was not indexed until the agent ran
memory_search. When the reload replaced only the embedding provider (Memory Core retained), managers kept resolving the retired provider.User Impact
Memory notes written after a plugin reload are indexed promptly by the current instance, for both reload shapes (Memory Core replaced, or only its embedding provider replaced). Retired instances no longer leave watchers running or log a failure on every file change.
Why This Change Was Made
onDisposenow runs the existing full manager drain, so a retired instance's watchers, timers, and listeners close with it.Keeps #167679's invariants: background work never adopts a replacement instance or retains a request context; retired work refuses. The same Gateway lifecycle owns service handoff and recovery; no SDK surface is added.
Evidence
openaiembeddings): first turn, then twoplugins.loadhot reloads, then a new memory file.sync failed (watch): Plugin openai was reloadedand not indexed (the provider-only gap, fixed by the second commit).977ebeb2ff1f(before the additional early-rollback repair): indexed 2.0 s after the write, 0 watch failures, 0 memory errors.memory_search. Covered by the replaced-instance regression.ac49c7f57703d5a09ad294eea82f8cf1ca95e113: 279 tests pass. The early-rollback regression fails on977ebeb2ff1f. Earlier watcher/provider regressions fail with production reverted. Types, lint, format, cycles (0), and build were previously verified.ac49c7f57703d5a09ad294eea82f8cf1ca95e113: complete, no actionable P0–P2 findings.