Task(max_turns=N)` is accepted but not enforced in Claude Code v2.1.19 interactive sessions. Subagents (e.g., Explore) continue far beyond the specified max_turns.

Resolved 💬 3 comments Opened Jan 24, 2026 by brendan-sherrin Closed Feb 27, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Bug

Task(max_turns=N) is accepted but not enforced in Claude Code v2.1.19 interactive sessions.
Subagents (e.g., Explore) continue far beyond the specified max_turns.

Environment

  • Claude Code: v2.1.19
  • OS: WSL2 Ubuntu (version: 24.04)
  • Model: Sonnet 4.5 (explicitly set)
  • Hooks: PreToolUse hook present (blocks when missing max_turns)

Expected

Task subagent stops at or before max_turns.

Actual

Agent continues well beyond max_turns (e.g. 97 tool uses / ~8 minutes) until manually interrupted.

Notes

  • CLI --max-turns works only in print mode (claude -p), but this issue is specifically about the Task tool parameter in interactive mode.

What Should Happen?

Task subagent stops at or before max_turns.

Error Messages/Logs

● Explore(Deep codebase exploration test)
  ⎿  
     +24 more tool uses (ctrl+o to expand)
  ⎿  Interrupted · What should Claude do instead?

● Yes, that confirms it - max_turns is NOT being respected.

  The agent showed "24+ more tool uses" before you interrupted it, meaning it was running well past the max_turns=10 limit I specified. If the parameter worked, it should have stopped after 10 API round-trips.

  Conclusion: The max_turns parameter in the Task tool appears to be either:
  1. Not implemented/enforced
  2. Ignored by the current task system
  3. Only used for some internal "warmup" purpose (as hinted in the schema: "Used internally for warmup")

  The schema description does say: "Maximum number of agentic turns (API round-trips) before stopping. Used internally for warmup." - so it may only be intended for internal initialization purposes, not for limiting exploration depth in normal usage.

Steps to Reproduce

  1. Start interactive Claude Code: claude
  2. Trigger a Task subagent with an explicit turn cap, e.g.:
  • Explore(Audit all scripts in .claude/scripts), max_turns=25
  1. Observe the agent continues significantly beyond 25 tool uses / turns.

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.19

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

WSL (Windows Subsystem for Linux)

Additional Information

WSL Ubuntu 24.04.3 LTS, Release: 24.04

View original on GitHub ↗

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