Skip to content

fix(memory): memory files stop indexing after plugin reloads until the next search - #167756

Merged
steipete merged 3 commits into
mainfrom
codex/stab-memory-watcher-retire
Oct 9, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/stab-memory-watcher-retire

Conversation

@steipete

@steipete steipete commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

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:

[memory] sync failed (watch): PluginInstanceUnavailableError: Plugin memory-core was reloaded or disabled; use its current tools.
[memory] sync failed (watch): Error: Plugin openai was reloaded or disabled; use its current tools.

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

  • Memory Core registered an instance-bound background runner but no disposal cleanup, and generic cache retirement bypassed the Gateway memory drain; its onDispose now runs the existing full manager drain, so a retired instance's watchers, timers, and listeners close with it.
  • The successor's index starts through the existing Gateway service lifecycle instead of waiting for the first search or turn.
  • Provider-only reloads: the Gateway now stops retained memory services before provider retirement and awaits their restart after publication and admission recovery (including rollback), so managers rebind to the current embedding provider. Early rollback restarts every drained previous memory owner, including replaced Memory Core, and awaits startup before reporting restoration. A rejected restart reports failed recovery. This is joined service handoff in the Gateway reload owner; no SDK change.

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

  • Live A/B, fresh state per side, same config (real OpenAI provider and openai embeddings): first turn, then two plugins.load hot reloads, then a new memory file.
    • main: no watcher, file never indexed in 60 s.
    • first watcher-retirement commit only: sync failed (watch): Plugin openai was reloaded and 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.
  • Lived-in dev Gateway on main (Memory Core replaced by the reload): retired watcher failed on every change (7 failures over 4 minutes), new note not indexed until memory_search. Covered by the replaced-instance regression.
  • Regressions (real registration, managers, file writes, SQLite indexing): replaced-instance watcher retirement + successor indexing without search/turn; four provider-only/rollback cases. All fail with production reverted.
  • Author-reported validation of ac49c7f57703d5a09ad294eea82f8cf1ca95e113: 279 tests pass. The early-rollback regression fails on 977ebeb2ff1f. Earlier watcher/provider regressions fail with production reverted. Types, lint, format, cycles (0), and build were previously verified.
  • Independent autoreview of ac49c7f57703d5a09ad294eea82f8cf1ca95e113: complete, no actionable P0–P2 findings.
  • Landing verification of the exact-head Gateway recovery suite: 111 tests pass in 72.82 s, including all six retained/replaced early-recovery cases. The earlier live proof above was not repeated during landing.

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.
@clawsweeper

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime extensions: memory-core Extension: memory-core size: L labels Oct 9, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Memory 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.

  • Before: The reported main run leaves the file unindexed until a search wakes memory indexing.
  • After: The reported candidate run indexes the file after the write with zero watcher failures.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The owner-boundary repair is useful and has credible reload evidence, but validation does not yet cover its changed startup behavior on existing installations.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: New memory notes stop becoming searchable after a plugin reload, and retired watchers repeatedly report failures.
Reason: The reported live failure affects existing automatic indexing. The author has established current-main involvement in the affected lifecycle area, and the repair remains within those owners.

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
Reviewed head: ac49c7f57703d5a09ad294eea82f8cf1ca95e113

Before merge

None.

Findings

None.

Tests

  • Low-value test extensions/memory-core/index.test.ts: starts configured indexes only for the selected memory slot: Remove the positive case’s exact mocked manager-call order assertion; it pins implementation shape rather than indexing behavior already exercised by stronger boundary coverage.
  • Missing end-to-end proof: The supplied evidence lacks a v2026.9.9-to-head Gateway startup run with existing memory settings and a populated index preserved.
Agent review details

How this fits together

Memory 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]
Loading

Technical review

Best 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

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current main still lacks this repair: Fetched main registers the instance-bound background runner but has no indexing service or disposal drain. The central production files are unchanged between the pinned base and fetched main. (extensions/memory-core/index.ts:208, 9490c112abba)
  • Instance-owned disposal and indexing: Disposal invokes the existing full manager drain. The indexing service is registered only when Memory Core owns the memory slot and closes managers through its stop callback. (extensions/memory-core/index.ts:216, ac49c7f57703)
  • Joined service recovery: Retained indexing services restart after registry adoption and memory admission recovery. Early rollback selects drained owners, stops their services, and awaits restart before restoration completes. (src/gateway/server-plugin-reload-services.ts:47, ac49c7f57703)
  • Recorded live reload comparison: The complete supplied body, sourceRevision fbef8a4558bd223c290b110d45e0226046d2e41584789ebb383fa0f222796749, records fresh-state development Gateways using real OpenAI embeddings. After a first turn, two plugins.load reloads, and a memory-file write, main failed to index while the second-commit candidate indexed successfully with zero memory errors. This evidence predates the final early-rollback commit and does not establish published-release upgrade behavior. (977ebeb2ff1f)
  • Behavioral rollback regressions: The added cases use real managers, file contents, and SQLite indexing to cover retained and replaced owners before drain, after drain, and on failed restart. The watch transport and embedding provider are fixtures; these are supplemental harness evidence. Tests and builds were not executed during this read-only review. (src/gateway/server-plugin-reload.recovery.test.ts:320, ac49c7f57703)
  • Earlier startup decision: fix(memory): keep gateway responsive after startup #119710 removed unsolicited all-agent memory initialization because it stalled post-ready health and configuration requests. This PR intentionally restores manager opening through service startup, without the old delayed warmup or explicit full synchronization. (extensions/memory-core/index.ts:229, 5eb7eddce69c)

Likely related people:

  • Peter Steinberger: Raw commit ee5dea9 adds extensions/memory-core/index.ts:217 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ee5dea9d11f9; files: extensions/memory-core/index.ts)

PR surface

Source +122, Tests +449, Docs +11. Total +582 across 12 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 158 36 +122
Tests 5 489 40 +449
Docs 1 11 0 +11
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 658 76 +582

Review metrics

Metric Value Why it matters
Production versus test growth Production +158/-36; tests/support +489/-40 Production growth implements disposal and joined recovery, while most growth exercises observable reload and indexing behavior.
Indexing lifecycle 1 new service; 2 configuration reload prefixes Configured indexes now open during service startup and restart for memory.search or agents changes.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Plugin reloads can silently stop indexing new memory files while the Gateway remains operational.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-09T09:45:44.226Z sha 977ebeb :: needs maintainer review before merge. :: none

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.
@steipete

steipete commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

@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 ac49c7f57703d5a09ad294eea82f8cf1ca95e113; the prior review covered 977ebeb2ff1f22efc5c0d88536c01c1a3df8fafb.

@clawsweeper

clawsweeper Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@steipete
steipete merged commit 0907600 into main Oct 9, 2026
137 checks passed
@steipete
steipete deleted the codex/stab-memory-watcher-retire branch October 9, 2026 10:06
@steipete

steipete commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 10, 2026
…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.
RomneyDa added a commit that referenced this pull request Oct 16, 2026
…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.
RomneyDa added a commit that referenced this pull request Oct 16, 2026
…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)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
…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.
RomneyDa added a commit that referenced this pull request Oct 20, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: memory-core Extension: memory-core gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L 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.

1 participant