From 6306424b83fb922bc47bf0e6fbb6f4749528d26e Mon Sep 17 00:00:00 2001 From: admtracksteel Date: Sun, 29 Mar 2026 01:00:58 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Auto-deploy:=20BotVPS=20atualiza?= =?UTF-8?q?do=20em=2029/03/2026=2001:00:58?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ai_agent.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ai_agent.py b/ai_agent.py index 690abe2..fde4cd8 100644 --- a/ai_agent.py +++ b/ai_agent.py @@ -82,10 +82,16 @@ DIRETRIZES: print(f"[AGENT] Iteração {i+1} - Enviando para {provider} (modelo padrão)...") response = await get_llm_response_async(system_prompt + current_history, provider, cfg) print(f"[LLM RESPONSE]: {response}") - match = re.search(r"\[TOOL:(.*?)\](.*?)\[/TOOL\]", response, re.I | re.S) + # Regex robusto que encontra o [TOOL:nome] e extrai o argumento mesmo sem [/TOOL] + match = re.search(r"\[TOOL:([^\]]+)\]", response, re.I) if match: - t_name, arg = match.group(1).strip(), match.group(2).strip() + t_name = match.group(1).strip() + content_after = response[match.end():] + end_tag = re.search(r"\[/TOOL\]", content_after, re.I) + + arg = content_after[:end_tag.start()].strip() if end_tag else content_after.strip() + if t_name in AVAILABLE_TOOLS: func = AVAILABLE_TOOLS[t_name]["func"] # Assume ferramentas são síncronas em tools.py (legado)