Answer: Cap turns and spend with `maxTurns` / `max_turns` and `maxBudgetUsd` / `max_budget_usd`; both caps are off when unset. When a session hits a cap, the run ends with a result message whose subtype is `error_max_turns` for the turn cap and `error_max_budget_usd` for the spend cap. Status: Confirmed Entry: tool/claude-code/pricing-and-limits/limit-turns-and-spend-sdk Revision: 3 Digest: sha256:75f3e66809e1db2f (changes whenever the content changes) Timeline: Created: 2026-11-13T03:02:39Z Last changed: 2026-11-20T12:16:22Z (maxBudgetUsd zero behavior: — → 0) Last verified: 2026-11-20T12:16:22Z Next check: 2026-11-21T12:16:22Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of turn cap option | maxTurns | [1] | 2026-11-20 spend cap option | maxBudgetUsd | [1] | 2026-11-20 turn cap result subtype | error_max_turns | [1] | 2026-11-20 spend cap result subtype | error_max_budget_usd | [1] | 2026-11-20 maxTurns zero behavior | 0 | [1] | 2026-11-20 maxBudgetUsd zero behavior | 0 | [1] | 2026-11-20 Sources: [1] Anthropic. "Configure your agent". https://code.claude.com/docs/en/agent-sdk/configuration.md Role: primary. Accessed: 2026-11-20T12:16:22Z Quote: "Cap turns and spend with `maxTurns` / `max_turns` and `maxBudgetUsd` / `max_budget_usd`." (Supports: turn cap option, spend cap option) Quote: "The result's subtype is `error_max_turns` for the turn cap and `error_max_budget_usd` for the spend cap." (Supports: turn cap result subtype, spend cap result subtype) Quote: "**`maxTurns` / `max_turns`**: `0` runs the session without a turn limit, the same as leaving the option unset" (Supports: maxTurns zero behavior) Quote: "**`maxBudgetUsd` / `max_budget_usd`**: the CLI rejects `0` as an invalid amount at startup, and the session never runs" (Supports: maxBudgetUsd zero behavior) Published: 2026-11-20T02:52:33Z Snapshot SHA-256: e8eaeff8e41acc725cb781af740f2c42a1e83825a7a3ebd74738d2f7136b13f5 (captured 2026-11-20T12:16:21Z) 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:22Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:16:22Z Last attempt: 2026-11-20T12:16:22Z Notes and limitations: Extracted automatically from a single official source (section "Limit turns and spend"). Related: https://latestn.com/tool/claude-code/pricing-and-limits/marketplace-download-limits What download limits apply to files hosted in a Claude Code plugin marketplace? https://latestn.com/tool/claude-code/pricing-and-limits/measure-plugin-token-cost How do I measure the token cost of a Claude Code plugin? https://latestn.com/tool/claude-code/pricing-and-limits/mod-limits What limits apply to Claude Code mods? https://latestn.com/tool/claude-code/pricing-and-limits/gateway-cost-attribution How do I attribute Claude apps gateway spend per developer or per team on AWS? https://latestn.com/tool/claude-code/pricing-and-limits/gateway-pricing-markup How do I mark up prices and send rates to signed-in clients in the Claude apps gateway? https://latestn.com/tool/claude-code/pricing-and-limits/limit-code-review-spend How do I limit how much my organization spends on Claude Code Review? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-20T12:16:22Z | changed | maxBudgetUsd zero behavior: — → 0 | [1] 2026-11-20T12:16:22Z | changed | maxTurns zero behavior: — → 0 | [1] 2026-11-20T12:16:22Z | changed | spend cap result subtype: — → error_max_budget_usd | [1] 2026-11-20T12:16:22Z | changed | turn cap result subtype: — → error_max_turns | [1] 2026-11-20T12:16:22Z | changed | spend cap option: — → maxBudgetUsd | [1] 2026-11-20T12:16:22Z | changed | turn cap option: — → maxTurns | [1] 2026-11-20T12:16:22Z | changed | Spend cap zero behavior: 0 → — | [1] 2026-11-20T12:16:22Z | changed | Turn cap zero behavior: 0 → — | [1] 2026-11-20T12:16:22Z | changed | Spend cap result subtype: error_max_budget_usd → — | [1] 2026-11-20T12:16:22Z | changed | Turn cap result subtype: error_max_turns → — | [1] 2026-11-20T12:16:22Z | changed | Spend cap option: maxBudgetUsd → — | [1] 2026-11-20T12:16:22Z | changed | Turn cap option: maxTurns → — | [1] 2026-11-17T12:20:17Z | changed | Spend cap zero behavior: — → 0 | [1] 2026-11-17T12:20:17Z | changed | Turn cap zero behavior: — → 0 | [1] 2026-11-17T12:20:17Z | changed | Spend cap result subtype: — → error_max_budget_usd | [1] 2026-11-17T12:20:17Z | changed | Turn cap result subtype: — → error_max_turns | [1] 2026-11-17T12:20:17Z | changed | Spend cap option: — → maxBudgetUsd | [1] 2026-11-17T12:20:17Z | changed | Turn cap option: — → maxTurns | [1] 2026-11-17T12:20:17Z | changed | maxBudgetUsd zero behavior: 0 → — | [1] 2026-11-17T12:20:17Z | changed | maxTurns zero behavior: 0 → — | [1] 2026-11-17T12:20:17Z | changed | Max budget result subtype: error_max_budget_usd → — | [1] 2026-11-17T12:20:17Z | changed | Max turns result subtype: error_max_turns → — | [1] 2026-11-17T12:20:17Z | changed | Default state: Both caps are off when unset → — | [1] 2026-11-17T12:20:17Z | changed | Budget limit option: maxBudgetUsd → — | [1] 2026-11-17T12:20:17Z | changed | Turn limit option: maxTurns → — | [1] 2026-11-13T03:02:39Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/claude-code/pricing-and-limits/limit-turns-and-spend-sdk/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/pricing-and-limits/limit-turns-and-spend-sdk POST: https://latestn.com/dispute/tool/claude-code/pricing-and-limits/limit-turns-and-spend-sdk with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/claude-code/pricing-and-limits/limit-turns-and-spend-sdk?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I limit the number of turns or spending in a Claude Code Agent SDK session? Revision 3, last verified 2026-11-20T12:16:22Z. https://latestn.com/tool/claude-code/pricing-and-limits/limit-turns-and-spend-sdk (accessed 2026-11-21T10:06:33Z). @misc{LatestN_tool_claude_code_pricing_and_limits_limit_turns_and_spend_sdk_r3, title = {How do I limit the number of turns or spending in a Claude Code Agent SDK session?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/claude-code/pricing-and-limits/limit-turns-and-spend-sdk}}, note = {Revision 3; digest sha256:75f3e66809e1db2f; last verified 2026-11-20T12:16:22Z; accessed 2026-11-21T10:06:33Z} } 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/pricing-and-limits/limit-turns-and-spend-sdk