Skip to content

Commit 8b02fa3

Browse files
committed
FEAT: retry send_message_and_get_response if it fails
1 parent b6dbbe4 commit 8b02fa3

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/eaa/agents/base.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
import json
9696
import logging
9797
import asyncio
98+
import time
9899

99100
import numpy as np
100101

@@ -723,8 +724,15 @@ def receive(
723724

724725
# Send messages, get response and print it.
725726
if request_response:
726-
response = self.send_message_and_get_response(combined_messages)
727-
print_message(response)
727+
for i in range(5):
728+
try:
729+
response = self.send_message_and_get_response(combined_messages)
730+
print_message(response)
731+
break
732+
except Exception as e:
733+
logger.error(f"Error sending message and getting response: {e}")
734+
logger.error(f"Retrying...({i+1}/5)")
735+
time.sleep(1)
728736

729737
if request_response and self.memory_manager is not None and message is not None:
730738
self._post_response_memory_update(

0 commit comments

Comments
 (0)