🧩maxTurns Option
Also known as maxTurns, max_turns, Agent SDK turn limit, Claude Agent SDK maxTurns
The option that caps how many turns an agent run may take.
Think of it like
It is like ten more turns on the swing, then you stop.
Example
Leo's agent sometimes loops on a hard bug. He sets maxTurns to 30, so it stops and reports instead of running on.
Why it matters
An open-ended task can run for a long time, and a cap keeps it in check.
Definition
Common mistake
Key takeaways
- 1Caps the turns. Per run.
- 2Final reply counts. Add one.
- 30 means no limit. Same as unset.