diff --git a/agent/memory_manager.py b/agent/memory_manager.py index d870d8dcc7..379e325c72 100644 --- a/agent/memory_manager.py +++ b/agent/memory_manager.py @@ -55,8 +55,11 @@ _INTERNAL_NOTE_RE = re.compile( def sanitize_context(text: str) -> str: - """Strip fence-escape sequences from provider output.""" - return _FENCE_TAG_RE.sub('', text) + """Strip fence tags, injected context blocks, and system notes from provider output.""" + text = _INTERNAL_CONTEXT_RE.sub('', text) + text = _INTERNAL_NOTE_RE.sub('', text) + text = _FENCE_TAG_RE.sub('', text) + return text def build_memory_context_block(raw_context: str) -> str: diff --git a/plugins/memory/honcho/__init__.py b/plugins/memory/honcho/__init__.py index a282af5078..4c1ccf7a38 100644 --- a/plugins/memory/honcho/__init__.py +++ b/plugins/memory/honcho/__init__.py @@ -774,6 +774,8 @@ class HonchoMemoryProvider(MemoryProvider): reasoning_level=reasoning_level, peer=peer, ) + # Update cadence tracker so auto-injection respects the gap after an explicit call + self._last_dialectic_turn = self._turn_count return json.dumps({"result": result or "No result from Honcho."}) elif tool_name == "honcho_context": diff --git a/plugins/memory/honcho/client.py b/plugins/memory/honcho/client.py index 6af7bfeb18..b65747ee7e 100644 --- a/plugins/memory/honcho/client.py +++ b/plugins/memory/honcho/client.py @@ -488,7 +488,7 @@ class HonchoClientConfig: # /title mid-session remap if session_title: - sanitized = re.sub(r'[^a-zA-Z0-9_-]', '-', session_title).strip('-') + sanitized = re.sub(r'[^a-zA-Z0-9_-]+', '-', session_title).strip('-') if sanitized: if self.session_peer_prefix and self.peer_name: return f"{self.peer_name}-{sanitized}" @@ -500,7 +500,7 @@ class HonchoClientConfig: # based resolution because gateway platforms need per-chat isolation that # cwd-based strategies cannot provide. if gateway_session_key: - sanitized = re.sub(r'[^a-zA-Z0-9_-]', '-', gateway_session_key).strip('-') + sanitized = re.sub(r'[^a-zA-Z0-9_-]+', '-', gateway_session_key).strip('-') if sanitized: return sanitized