[BUG]

Resolved 💬 2 comments Opened Jul 10, 2025 by soyrubio Closed Jul 10, 2025

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.44
  • Operating System: macOS Sequoia
  • Terminal: Cursor's integrated, zsh

Bug Description

Claude Code seems to ignore the --max-turns flag, at least when having a session resumed. See my prompt below

> claude -p --output-format json --max-turns 3 --resume <sessionId> "give me info on the files"
{"type":"result","subtype":"error_max_turns","duration_ms":6118,"duration_api_ms":5948,"is_error":false,"num_turns":3"session_id":"<sessionId>","total_cost_usd":0.056918250000000004,"usage":{"input_tokens":4,"cache_creation_input_tokens":11,"cache_read_input_tokens":33518,"output_tokens":85,"server_tool_use":{"web_search_requests":0},"service_tier":"standard"}}

> claude -p --output-format json --max-turns 3 --resume <sessionId>
{"type":"result","subtype":"success","is_error":false,"duration_ms":15448,"duration_api_ms":15268,"num_turns":11,"result":"<result>","session_id":"<sessionId>","total_cost_usd":0.421000000002302,"usage":{"input_tokens":4,"cache_creation_input_tokens":20136,"cache_read_input_tokens":13389,"output_tokens":350,"server_tool_use":{"web_search_requests":0},"service_tier":"standard"}}

I have nullified the message and sessionId here, but all other data remains unchained. I have ran the same previous

Expected Behavior

Claude would stop after 3 turns

Actual Behavior

Claude does not stop after 3 turns and proceeds to do 11.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗