Sub-agent has no tool call / token / time limits, causing unbounded token consumption

Resolved 💬 6 comments Opened Mar 20, 2026 by syedqzaidi Closed May 2, 2026

Root Cause Analysis: Sub-agent unbounded tool call loop causes excessive token consumption

Problem Statement

When the orchestrating agent dispatches a sub-agent (via the Agent tool) with a research-oriented prompt, the sub-agent has no upper bound on tool calls. In the observed case, a single sub-agent made 234 tool calls (WebSearch + WebFetch) and the research phase alone took almost 1.5 hours of wall-clock time. Total session token consumption exceeded 124K tokens — for a task where the information the sub-agent was searching for was already present in its own prompt.

A second sub-agent performing an equivalent task completed in 39 tool calls, demonstrating high variance in sub-agent behavior for identical task structures.

Root Cause

There is no mechanism to limit the number of tool calls a sub-agent can make. The Agent tool accepts a prompt and dispatches a sub-agent, but provides no parameters to constrain:

  1. Maximum tool calls — a sub-agent can make unlimited tool calls with no ceiling
  2. Maximum token budget — there is no way to cap how many tokens a sub-agent consumes
  3. Time limit — there is no timeout parameter on the Agent tool itself (the Bash tool has one, but Agent does not)

This creates a failure mode where:

  • The orchestrating agent dispatches a sub-agent for web research
  • The sub-agent interprets its research mandate broadly and performs exhaustive searches
  • Each WebSearch yields results that suggest further searches (rabbit-holing)
  • The sub-agent has no signal to stop — it continues until it subjectively decides it has "enough" information
  • The orchestrating agent has no visibility into or control over this behavior while it is happening

Contributing Factors

  1. No feedback loop during execution — the orchestrating agent cannot monitor sub-agent progress, token consumption, or tool call count while the sub-agent is running. It only sees the final result.
  1. Sub-agent prompt interpretation is unbounded — a prompt like "research X using WebSearch" gives the sub-agent no guidance on how many searches constitute sufficient research. Different sub-agent instances interpret this differently (234 vs 39 calls for equivalent tasks).
  1. WebSearch results encourage further searching — each search result contains links and references that a thorough research agent will follow, creating an expanding search tree with no natural termination condition.
  1. No cost awareness — sub-agents have no visibility into their own token consumption or the user's remaining budget. They optimize for thoroughness, not efficiency.

Impact

  • Token waste: Total session exceeded 124K tokens, the vast majority consumed by unnecessary sub-agent web research
  • Time waste: Research phase alone took almost 1.5 hours of wall-clock time on web searches that produced information already available in context
  • Unpredictable costs: Users cannot predict or control how many tokens a sub-agent will consume, making cost planning impossible
  • No recourse: Tokens consumed by runaway sub-agents cannot be recovered

Proposed Fix

Add optional constraint parameters to the Agent tool:

// Proposed additions to Agent tool parameters
{
  "max_tool_calls": {
    "description": "Maximum number of tool calls the sub-agent can make before returning",
    "type": "number"
  },
  "max_tokens": {
    "description": "Maximum token budget for this sub-agent execution",
    "type": "number"
  },
  "timeout_ms": {
    "description": "Maximum wall-clock time in milliseconds before the sub-agent is terminated",
    "type": "number"
  }
}

Additionally, the orchestrating agent should be trained to:

  • Recognize when information is already present in the prompt/context and skip redundant research
  • Set appropriate constraints when dispatching research-oriented sub-agents
  • Default to conservative tool call limits unless explicitly told to be exhaustive

Reproduction

  1. Dispatch a sub-agent via the Agent tool with a prompt that includes: (a) a list of specific topics to research, and (b) instructions to use WebSearch/WebFetch
  2. Observe that the sub-agent has no upper bound on tool calls
  3. Compare token consumption across multiple runs of the same prompt — variance is high and unpredictable

Environment

  • Model: Claude Opus 4.6 (1M context)
  • Platform: macOS (Darwin 24.6.0)
  • Agent tool sub-agent type: general-purpose

View original on GitHub ↗

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