MaxTurnsExceeded error during agent tool execution – unable to retrieve final output

Hi everyone,

I’m encountering a MaxTurnsExceeded error while running agents, most frequently during tool calling execution.

Issue description:

  • The agent hits MaxTurnsExceeded while 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/except block

  • 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:

  1. What is the root cause of MaxTurnsExceeded in agent tool execution?

  2. Is there a way to retrieve partial or intermediate tool results after this error occurs?

  3. Are there recommended best practices to prevent agents from hitting the max turn limit during tool calls?