From f7a50472280623c537f8d4e4cfd51aee568cc2a2 Mon Sep 17 00:00:00 2001 From: Giuseppe Castelluccio Date: Mon, 15 Jun 2026 09:11:29 +0200 Subject: [PATCH] fix(memory): fall back to utility endpoint when import session is stale (#3428) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- routes/memory_routes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/routes/memory_routes.py b/routes/memory_routes.py index b1466c660..e788f82d2 100644 --- a/routes/memory_routes.py +++ b/routes/memory_routes.py @@ -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))