Answer: You control the agent loop with Max turns (`max_turns` / `maxTurns`), which sets the maximum number of turns, and Max budget (`max_budget_usd` / `maxBudgetUsd`), which sets the estimated spend at which the loop stops; both default to No limit. Status: Confirmed Entry: tool/claude-code/agents-and-automation/control-turns-and-budget Revision: 2 Digest: sha256:48cbd69f627d595f (changes whenever the content changes) Timeline: Created: 2026-11-13T03:02:36Z Last changed: 2026-11-20T12:16:13Z (Max budget error subtype: error_max_budget_usd → —) Last verified: 2026-11-20T12:16:13Z Next check: 2026-11-21T12:16:13Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of Max turns option | max_turns | [1] | 2026-11-20 Max turns default | No limit | [1] | 2026-11-20 Max budget option | max_budget_usd | [1] | 2026-11-20 Max budget default | No limit | [1] | 2026-11-20 Max turns error subtype | error_max_turns | [1] | 2026-11-20 Cap-enforcement version | v2.1.217 | [1] | 2026-11-20 Sources: [1] Anthropic. "How the agent loop works". https://code.claude.com/docs/en/agent-sdk/agent-loop.md Role: primary. Accessed: 2026-11-20T12:16:13Z Quote: "Max turns (`max_turns` / `maxTurns`)" (Supports: Max turns option) Quote: "| Max turns (`max_turns` / `maxTurns`) | Maximum number of [turns](#turns-and-messages) | No limit |" (Supports: Max turns default) Quote: "Max budget (`max_budget_usd` / `maxBudgetUsd`)" (Supports: Max budget option) Quote: "| Max budget (`max_budget_usd` / `maxBudgetUsd`) | Estimated spend at which the loop stops | No limit |" (Supports: Max budget default) Quote: "(`error_max_turns` or `error_max_budget_usd`)" (Supports: Max turns error subtype) Quote: "The cap-enforcement behaviors require Claude Code v2.1.217 or later." (Supports: Cap-enforcement version) Published: 2026-11-20T02:53:15Z Snapshot SHA-256: 55a463c38057a4f24a8c6ffe8eb4984a5285d0e3eda21f982a81cc193bb4ad5b (captured 2026-11-20T12:16:13Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. Cross-check: not-available at 2026-11-20T12:16:13Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:16:13Z Last attempt: 2026-11-20T12:16:13Z Notes and limitations: Extracted automatically from a single official source (section "Turns and budget"). Related: https://latestn.com/tool/claude-code/agents-and-automation/create-custom-subagent How do I create a custom subagent in Claude Code? https://latestn.com/tool/claude-code/agents-and-automation/create-custom-tool How do I create a custom tool for Claude Code using the Agent SDK? https://latestn.com/tool/claude-code/agents-and-automation/create-scheduled-task How do I create a scheduled task in Claude Code Desktop? https://latestn.com/tool/claude-code/agents-and-automation/configure-hooks How do I configure hooks in Claude Code to intercept tool calls? https://latestn.com/tool/claude-code/agents-and-automation/configure-tool-search How do I configure tool search in Claude Code? https://latestn.com/tool/claude-code/agents-and-automation/continue-conversations How do I continue a conversation when running Claude Code programmatically? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-20T12:16:13Z | changed | Max budget error subtype: error_max_budget_usd → — | [1] 2026-11-13T03:02:36Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/claude-code/agents-and-automation/control-turns-and-budget/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/claude-code/agents-and-automation/control-turns-and-budget POST: https://latestn.com/dispute/tool/claude-code/agents-and-automation/control-turns-and-budget with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/claude-code/agents-and-automation/control-turns-and-budget?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I control how many turns or budget a Claude Code agent loop runs? Revision 2, last verified 2026-11-20T12:16:13Z. https://latestn.com/tool/claude-code/agents-and-automation/control-turns-and-budget (accessed 2026-11-21T10:07:29Z). @misc{LatestN_tool_claude_code_agents_and_automation_control_turns_and_budget_r2, title = {How do I control how many turns or budget a Claude Code agent loop runs?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/claude-code/agents-and-automation/control-turns-and-budget}}, note = {Revision 2; digest sha256:48cbd69f627d595f; last verified 2026-11-20T12:16:13Z; accessed 2026-11-21T10:07:29Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/claude-code/agents-and-automation/control-turns-and-budget