Skip to content

The agent that grows with you

fix(memory): keep the memory-context helpers importable from agent.memory_manager

unsupportedpastels5e4c8231ab03
diff --git a/agent/memory_manager.py b/agent/memory_manager.py
index f0ec422710d..71af356bb5c 100644
--- a/agent/memory_manager.py
+++ b/agent/memory_manager.py
@@ -19,6 +19,9 @@ from typing import Any, Callable, Dict, List, Optional
from agent.redact import redact_for_egress
from agent.memory_caller_scope import caller_scope, claim_instance, in_owner_home, refused_tool_message
+# Moved to agent.memory_context; still importable here because agent.memory_manager is a public
+# module for plugins (hermes_cli/plugin_validate_private_imports.py).
+from agent.memory_context import StreamingContextScrubber, build_memory_context_block, sanitize_context
from agent.memory_provider import MemoryProvider, PRE_COMPRESS_CHECKPOINT_API_VERSION, ctx_bound, spawn_context_thread
from agent.skill_commands import extract_user_instruction_from_skill_message
from tools.hook_output_spill import get_spill_config, spill_if_oversized
diff --git a/tests/agent/test_streaming_context_scrubber.py b/tests/agent/test_streaming_context_scrubber.py
index 3ed30b5405e..726abce12f0 100644
--- a/tests/agent/test_streaming_context_scrubber.py
+++ b/tests/agent/test_streaming_context_scrubber.py
@@ -1,4 +1,4 @@
-"""Unit tests for StreamingContextScrubber (agent/memory_manager.py).
+"""Unit tests for StreamingContextScrubber (agent/memory_context.py).
Regression coverage for #5719 — memory-context spans split across stream
deltas must not leak payload to the UI. The one-shot sanitize_context()
@@ -182,3 +182,12 @@ class TestBuildMemoryContextBlockWarnsOnViolation:
assert not any("pre-wrapped" in rec.message for rec in caplog.records)
assert "plain fact about user" in out
+
+
+def test_old_memory_manager_import_path_still_resolves():
+ # agent.memory_manager is a public module for plugins (plugin_validate_private_imports._PUBLIC),
+ # so the helpers that moved to agent.memory_context stay importable from it.
+ import agent.memory_context as moved
+ import agent.memory_manager as old
+ for name in ("sanitize_context", "StreamingContextScrubber", "build_memory_context_block"):
+ assert getattr(old, name, None) is getattr(moved, name), name