Hi everyone,
I’m encountering a MaxTurnsExceeded error while running agents, most frequently during tool calling execution.
Issue description:
-
The agent hits
MaxTurnsExceededwhile executing or chaining tool calls. -
When this happens, the agent terminates and I’m unable to retrieve the final agent output or the last tool result, even though some work appears to have been completed.
What I’ve tried:
-
Wrapping execution in a
try/exceptblock -
Retrying one more tool-calling iteration after catching the exception
However, the same MaxTurnsExceeded exception is raised again, and the output is still not retrievable.
Questions:
-
What is the root cause of
MaxTurnsExceededin agent tool execution? -
Is there a way to retrieve partial or intermediate tool results after this error occurs?
-
Are there recommended best practices to prevent agents from hitting the max turn limit during tool calls?