Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ def long_memory_update_process(
original_memory=cur_working_memory,
new_memory=new_candidates,
)
# Drop batch references explicitly: scheduler threads are long-lived and
# reused, so locals otherwise linger until the next batch overwrites them.
del cur_working_memory, new_candidates
import gc

gc.collect()
logger.debug(
"[long_memory_update_process] Final working memory size: %s memories for user_id=%s",
len(new_order_working_memory),
Expand Down Expand Up @@ -273,5 +279,15 @@ def process_session_turn(
item,
"\n- ".join([f"{one.id}: {one.memory}" for one in results]),
)
# Strip embeddings from candidates: vectors are retrieval artifacts,
# not needed for working-memory replacement decisions. On busy
# deployments these lists survive across batches and pile up
# (observed ~3.4GB retained across ~900 batches in production).
for _r in results:
try:
if getattr(_r.metadata, "embedding", None):
_r.metadata.embedding = None
except Exception:
pass
new_candidates.extend(results)
return cur_working_memory, new_candidates
Loading