From 5118692c256742c71efd203d556719ea832d41cd Mon Sep 17 00:00:00 2001 From: kshitij <82637225+kshitijk4poor@users.noreply.github.com> Date: Thu, 13 Aug 2026 22:20:51 +0530 Subject: [PATCH] fix: replace double-lambda with functools.partial, close from_env config_path gap - _submit_background and _prefetch_provider: replace unreadable (lambda inner: (lambda: ctx.run(inner)))(fn) with functools.partial(ctx.run, fn) - from_env(): set config_path=resolve_config_path() so bound_config_path() doesn't re-resolve from ContextVar on daemon threads (the exact bug the PR fixes for from_global_config) Review follow-ups for salvaged PR #83525. --- agent/memory_manager.py | 7 ++++--- plugins/memory/honcho/client.py | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/agent/memory_manager.py b/agent/memory_manager.py index 27e90db579e63..5b57dd16f478c 100644 --- a/agent/memory_manager.py +++ b/agent/memory_manager.py @@ -562,10 +562,10 @@ class MemoryManager: # Propagate the caller's contextvars (profile HERMES_HOME override) # to the prefetch thread — see _submit_background. import contextvars + from functools import partial - _ctx = contextvars.copy_context() thread = threading.Thread( - target=lambda: _ctx.run(_run), + target=partial(contextvars.copy_context().run, _run), daemon=True, name=f"memory-prefetch-{provider.name}", ) @@ -743,9 +743,10 @@ class MemoryManager: from the worker would silently land on the default profile. """ import contextvars + from functools import partial ctx = contextvars.copy_context() - fn = (lambda inner: (lambda: ctx.run(inner)))(fn) + fn = partial(ctx.run, fn) executor = self._get_sync_executor() if executor is None: if self._shutting_down: diff --git a/plugins/memory/honcho/client.py b/plugins/memory/honcho/client.py index 9bc27ca23347d..42bb378c445f6 100644 --- a/plugins/memory/honcho/client.py +++ b/plugins/memory/honcho/client.py @@ -491,6 +491,7 @@ class HonchoClientConfig: api_key = get_secret("HONCHO_API_KEY") base_url = os.environ.get("HONCHO_BASE_URL", "").strip() or None timeout = _resolve_optional_float(os.environ.get("HONCHO_TIMEOUT")) + _resolved_path = resolve_config_path() return cls( host=resolved_host, workspace_id=workspace_id, @@ -500,6 +501,7 @@ class HonchoClientConfig: timeout=timeout, ai_peer=resolved_host, enabled=bool(api_key or base_url), + config_path=_resolved_path, hermes_home=get_hermes_home(), )