This commit is contained in:
Classic298 2026-09-30 10:36:36 -06:00 • committed by GitHub
commit 8f83fd46ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -403,6 +403,9 @@ async def add_memory_context(request, form_data: dict, user, model: dict | None
return form_data
memory_context = f'{MEMORY_CONTEXT_OPEN}\n{rendered}\n{MEMORY_CONTEXT_CLOSE}'
if messages and messages[0].get('role') == 'system':
# Without a blank line, models echo the block as part of the prompt
memory_context = f'\n{memory_context}'
form_data['messages'] = add_or_update_system_message(memory_context, messages, append=True)
return form_data