fix(memory): fall back to utility endpoint when import session is stale (#3428)

When a session ID is sent to POST /api/memory/import but that session no
longer exists in the DB, the previous code raised HTTP 404.  The import
endpoint only needs the session as an LLM-config source; the file being
imported has nothing to do with the session.  A fallback to the utility
endpoint (already used when no session_id is supplied at all) is correct
and safe.

The extract endpoint is intentionally left alone — it reads the session's
message history and therefore genuinely requires a live session.

Co-authored-by: clochard04 <clochard724@gmail.com>
This commit is contained in:
Giuseppe Castelluccio
2026-06-15 09:11:29 +02:00
committed by GitHub
parent 4ccb7c4890
commit f7a5047228
+2 -1
View File
@@ -377,7 +377,8 @@ def setup_memory_routes(memory_manager: MemoryManager, session_manager: SessionM
sess.endpoint_url, sess.model, sess.headers, owner=_owner(request)
)
except KeyError:
raise HTTPException(404, "Session not found — needed for LLM config")
logger.warning("Session %s not found, falling back to utility endpoint", session)
endpoint_url, model, headers = resolve_endpoint("utility", owner=_owner(request))
else:
endpoint_url, model, headers = resolve_task_endpoint(owner=_owner(request))