mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-27 01:11:40 +00:00
fix: harden memory-context leak boundaries
This commit is contained in:
parent
3ce47677e9
commit
936ac82fe5
7 changed files with 108 additions and 6 deletions
|
|
@ -22,6 +22,7 @@ import threading
|
|||
import time
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from agent.memory_manager import sanitize_context
|
||||
from agent.memory_provider import MemoryProvider
|
||||
from tools.registry import tool_error
|
||||
|
||||
|
|
@ -1068,13 +1069,15 @@ class HonchoMemoryProvider(MemoryProvider):
|
|||
return
|
||||
|
||||
msg_limit = self._config.message_max_chars if self._config else 25000
|
||||
clean_user_content = sanitize_context(user_content or "").strip()
|
||||
clean_assistant_content = sanitize_context(assistant_content or "").strip()
|
||||
|
||||
def _sync():
|
||||
try:
|
||||
session = self._manager.get_or_create(self._session_key)
|
||||
for chunk in self._chunk_message(user_content, msg_limit):
|
||||
for chunk in self._chunk_message(clean_user_content, msg_limit):
|
||||
session.add_message("user", chunk)
|
||||
for chunk in self._chunk_message(assistant_content, msg_limit):
|
||||
for chunk in self._chunk_message(clean_assistant_content, msg_limit):
|
||||
session.add_message("assistant", chunk)
|
||||
self._manager._flush_session(session)
|
||||
except Exception as e:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue