Limit Agent retries

I’ve created a CrewAI flow with multiple agents and tasks and one of the agents runs multiple times while the first response is already sufficient.

I’ve set the max_iter=1 setting for the agent to 1 but it still runs twice.

How can I avoid that the agent runs multiple times?

Regards,
Stefan

Can you confirm that’s actually true? Set the verbose parameter to True to all your agents and crews to see what’s happening behind the scenes. Once you do this, please copy-paste content from the terminal here. Of course, remove any sensitive data.

1 Like

@stefanstranger The agent runs the same task twice, or is it a different task?

I am experiencing the same problem. It is the same tasks.

@m1k3y02 Which CrewAI SDK version are you using? Try to downgrade it a bit to see if the issue dissapears. Let me know the results. If downgrading solves the issue, then the SDK might have a bug.

@stefanstranger Which CrewAI SDK version are you using? Try to downgrade it a bit to see if the issue dissapears. Let me know the results. If downgrading solves the issue, then the SDK might have a bug.

@rokbenko I am running crewai version: 0.83.0

If you downgrade it to 0.80.0, does the issue persist?

@rokbenko I downgraded to 0.80.0, and issue seems to persist, but when I went down to 0.79.0, it seems to work fine or at least started again respecting the params like max_iter and max_execution_time

@m1k3y02 I’ll let CrewAI staff know and get back to you.

1 Like

Great to hear. Thanks a ton!

Please let them know the following:

  1. I didn’t try on 0.79.4
  2. This is an intermittent issue.
  3. I encountered it with gpt-4o and gpt-4o-mini
  4. The issue happens only when agents have access to tools

@m1k3y02 I passed along the additional information you provided. They’re looking at it.

1 Like

Hi @stefanstranger @m1k3y02 ,

We are still looking into this

Could you please share how you are configuring the task(s)?

Hi Matt,
Can you please let me know what exactly are you looking for?