fix: harden memory-context leak boundaries

This commit is contained in:
dontcallmejames 2026-04-21 16:01:10 -04:00 committed by Erosika
parent 3ce47677e9
commit 936ac82fe5
7 changed files with 108 additions and 6 deletions

View file

@ -22,6 +22,8 @@ import sqlite3
import threading
import time
from pathlib import Path
from agent.memory_manager import sanitize_context
from hermes_constants import get_hermes_home
from typing import Any, Callable, Dict, List, Optional, TypeVar
@ -1119,7 +1121,10 @@ class SessionDB:
rows = cursor.fetchall()
messages = []
for row in rows:
msg = {"role": row["role"], "content": row["content"]}
content = row["content"]
if row["role"] in {"user", "assistant"} and isinstance(content, str):
content = sanitize_context(content).strip()
msg = {"role": row["role"], "content": content}
if row["tool_call_id"]:
msg["tool_call_id"] = row["tool_call_id"]
if row["tool_name"]: