History cleaning: stripping footer from previous messages to avoid LLM confusion

This commit is contained in:
2026-05-01 14:34:51 +00:00
parent 59dbd02d8d
commit 922f36c0b8

View File

@@ -73,7 +73,9 @@ DIRETRIZES:
history_str = ""
if chat_history:
for m in chat_history[-5:]:
history_str += f"\nUsuário: {m['user']}\nAgente: {m['bot']}\n"
# Remove o rodapé (---) da mensagem do bot para não confundir a IA
bot_msg = m['bot'].split("\n\n---")[0] if "\n\n---" in m['bot'] else m['bot']
history_str += f"\nUsuário: {m['user']}\nAgente: {bot_msg}\n"
history_str += f"\nUsuário: {prompt}\n"
current_history = history_str