feat: add 3-second API cooldown between turns to avoid Gemini 429 rate limit

This commit is contained in:
Rui
2026-05-17 03:12:30 +02:00
parent 46f6adb464
commit 985c6e9e0a
+4
View File
@@ -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: