Skip to content

fix(memos-local): L2 candidate stuck + bridge subprocess leak#1933

Open
a844810597 wants to merge 2 commits into
MemTensor:mainfrom
a844810597:main
Open

fix(memos-local): L2 candidate stuck + bridge subprocess leak#1933
a844810597 wants to merge 2 commits into
MemTensor:mainfrom
a844810597:main

Conversation

@a844810597

@a844810597 a844810597 commented Jun 16, 2026

Copy link
Copy Markdown

Fix 1: L2 Candidate Policy stuck in candidate

A candidate policy whose support/gain satisfy thresholds but is no longer
cosine-matched by any trace never enters touched and nextStatus()
is never executed. Add Step 5 after Step 4 to scan all candidate policies.

File: apps/memos-local-plugin/core/memory/l2/l2.ts +42/-1

Fix 2: Bridge subprocess leak via weakref + del

The keepalive thread closure captured self directly, creating a reference
cycle that prevented GC. Combined with missing del, leaked providers
leave bridge subprocesses alive indefinitely.

  1. weakref — break the reference cycle
  2. del — safety net for missed shutdown()

File: apps/memos-local-plugin/adapters/hermes/memos_provider/init.py +41/-8


No interface changes. Normal paths unaffected.

… recheck

A candidate policy whose support/gain already satisfy the promotion
thresholds (support >= minSupport && gain >= minGain) but is no longer
cosine-matched by any trace in subsequent episodes will never enter
'touched' and therefore nextStatus() is never executed.

Add Step 5 after Step 4 to scan all candidate policies and promote any
whose stored support/gain already meet the thresholds.

Fixes MemTensor#1932
…el__

The keepalive thread closure in _start_bridge_keepalive captured self
directly, creating a reference cycle that prevented GC from collecting
the provider. Combined with the missing __del__, a leaked provider
would leave its bridge subprocess (Popen) and keepalive thread alive
indefinitely.

Two complementary fixes:

1. weakref — break the reference cycle so GC can collect the provider
   when all external references are dropped.

2. __del__ — safety net that calls shutdown() during GC when the caller
   forgot to invoke it explicitly (e.g. model/routing change paths
   that assign self.agent = None without calling shutdown).

Both are required: weakref enables GC collection, __del__ ensures
cleanup happens when collection occurs.
@a844810597 a844810597 changed the title fix(memos-local): L2 candidate policy stuck in candidate — add Step 5 recheck fix(memos-local): L2 candidate stuck + bridge subprocess leak Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant