From 922f36c0b8b64839acfa0b266c78236c95a33d83 Mon Sep 17 00:00:00 2001 From: admtracksteel Date: Fri, 1 May 2026 14:34:51 +0000 Subject: [PATCH] History cleaning: stripping footer from previous messages to avoid LLM confusion --- ai_agent.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ai_agent.py b/ai_agent.py index ee1167e..906a054 100644 --- a/ai_agent.py +++ b/ai_agent.py @@ -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