I have setup a basic crew. Due to limits on bedrock quota , the crew run gets error-out. What is the best way to set exponential back-off in individual agents to fix this?
The only way I found to solve this is modifying the Task class so that it doesn’t raise an exception when the task fails, but just waits for a fixed amount of time and then retries. This doesn’t cause the crew to end up in error
def _execute_core(
self,
agent: Optional[BaseAgent],
context: Optional[str],
tools: Optional[List[Any]],
max_retries: Optional[int] = 5,
delay: Optional[int] = 5,
) -> TaskOutput:
...
...
...
except Exception as e:
self.end_time = datetime.datetime.now()
crewai_event_bus.emit(self, TaskFailedEvent(error=str(e), task=self))
if max_retries > 0:
# Retry task execution
time.sleep(delay)
max_retries -= 1
return self._execute_core(agent, context, tools, max_retries, delay)
else:
crewai_event_bus.emit(self, TaskCompletedEvent(output=TaskOutput(description="Task failed", agent=self.agent.role), task=self))
#raise e # Re-raise the exception after emitting the event
Here for more details