fix: track and join honcho-memwrite thread in shutdown

on_memory_write spawns a fire-and-forget daemon thread that was never
stored on self, so shutdown() couldn't join it — the exact problem the
PR fixes for the async writer thread. Store as self._memwrite_thread
and include it in the shutdown join loop.

Review follow-up for salvaged PR #83500.
This commit is contained in:
kshitij 2026-08-13 22:32:34 +05:30
parent 9e77d83354
commit 1226970001
1 changed files with 3 additions and 3 deletions

View File

@ -1496,8 +1496,8 @@ class HonchoMemoryProvider(MemoryProvider):
except Exception as e:
logger.debug("Honcho memory mirror failed: %s", e)
t = spawn_context_thread(_write, name="honcho-memwrite")
t.start()
self._memwrite_thread = spawn_context_thread(_write, name="honcho-memwrite")
self._memwrite_thread.start()
def on_session_end(self, messages: List[Dict[str, Any]]) -> None:
"""Flush all pending messages to Honcho on session end."""
@ -1672,7 +1672,7 @@ class HonchoMemoryProvider(MemoryProvider):
return tool_error(f"Honcho {tool_name} failed: {e}")
def shutdown(self) -> None:
for t in (self._prefetch_thread, self._sync_thread):
for t in (self._prefetch_thread, self._sync_thread, getattr(self, "_memwrite_thread", None)):
if t and t.is_alive():
t.join(timeout=5.0)
manager = self._manager