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
This commit is contained in:
Classic298
2026-09-22 11:35:14 -04:00
committed by GitHub
parent f956f7adc0
commit 6b36f620cf
+1 -1
View File
@@ -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 {},