From 985c6e9e0a92786307322ba4c27382e64ce0f742 Mon Sep 17 00:00:00 2001 From: Rui Date: Sun, 17 May 2026 03:12:30 +0200 Subject: [PATCH] feat: add 3-second API cooldown between turns to avoid Gemini 429 rate limit --- templates/agent_executor.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/templates/agent_executor.py b/templates/agent_executor.py index d36a47d..69c6e66 100644 --- a/templates/agent_executor.py +++ b/templates/agent_executor.py @@ -6,6 +6,7 @@ import base64 import random import urllib.request import urllib.error +import time class SwarmAgent: def __init__(self, task_data): @@ -172,6 +173,9 @@ class SwarmAgent: # Loop de multi-turn de ferramentas (máximo 15 iterações) for turn in range(15): print(f" [>] Iniciando turno {turn + 1} com o cérebro Gemini...") + if turn > 0: + print(" [>] Resfriando a API por 3 segundos para evitar rate limit (429)...") + time.sleep(3.0) try: response = self.call_gemini(contents, system_instruction, api_key) except Exception as e: