From 6b36f620cf6eda7df58e04f1aed4e86cf1e52062 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Tue, 22 Sep 2026 17:35:14 +0200 Subject: [PATCH] fix: stop KeyError 'model' traceback on every new chat from initial title generation (#30356) Every new saved chat logged "Error generating initial chat title" with a KeyError: 'model' traceback. The title itself was already generated and saved by then, so the log was misleading, and the memory settings played no part in it. The error was silently logged at debug level since v0.10.0 and became visible in v0.11.4 when the title path switched to log.exception. The initial title task runs the shared background handler with a context that has no resolved model, which the memory review step read unconditionally. It now reads it with a default of None, which the memory review already accepts. The title path never carries an assistant message, so the review stops before doing any work there, and the main completion path keeps reviewing memory exactly once per turn with the real model. Fixes #30339 --- backend/open_webui/utils/middleware.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 0cb0f2b6d9..523c8bff8b 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -4041,7 +4041,7 @@ async def background_tasks_handler(ctx): await review_memory_after_turn( request=request, user=user, - model=ctx['model'], + model=ctx.get('model'), metadata=metadata, form_data=form_data, assistant_message=ctx.get('assistant_message') or {},