fix: make session search initialize session db

This commit is contained in:
HenkDz 2026-05-03 17:43:53 +01:00 committed by Teknium
parent 9c26297c80
commit 840ebe063e
8 changed files with 220 additions and 11 deletions

View file

@ -337,8 +337,14 @@ def session_search(
The current session is excluded from results since the agent already has that context.
"""
if db is None:
from hermes_state import format_session_db_unavailable
return tool_error(format_session_db_unavailable(), success=False)
try:
from hermes_state import SessionDB
db = SessionDB()
except Exception:
logging.debug("SessionDB unavailable for session_search", exc_info=True)
from hermes_state import format_session_db_unavailable
return tool_error(format_session_db_unavailable(), success=False)
# Defensive: models (especially open-source) may send non-int limit values
# (None when JSON null, string "int", or even a type object). Coerce to a