[BUG] Sonnet 5 issues 1000 agents suddenly and burned 13M tokens for no reason

Status Open
Reported on v2.1.219
Maintainer reply None cached
Activity 3 comments · opened Jul 26, 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?

I asked it to simply code some text, but for some reason it catastrophicly failed. it read per character instead of array then it summons 1000 agents for now reason

claude-code-workflow-bug-report.md

What Should Happen?

it should fEither (a) the platform detects that args was received as a raw string when the script's usage pattern clearly expects an object/array, and fails the call immediately with a clear diagnostic (e.g. "args was passed as a JSON string, not a parsed value — did you mean to pass an object/array directly?"), or (b) at minimum, a workflow that fans out to a number of agent()/parallel() calls far beyond the platform's own stated default guideline (this session's config said "keep workflows under 15 agents") should hard-stop with a warning instead of silently proceeding to spawn thousands of agents. Separately, a workflow racking up a long unbroken run of consecutive agent failures (e.g. "session limit" errors, which are non-retryable within the session) should stop scheduling further calls rather than continuing to the full 1000-call cap. And the completion <summary> line should reflect a catastrophic error rate (e.g. "completed — 800/1000 agent calls errored") instead of reading identically to a healthy run.ix the bug at least if it should think that summoning 1000 agents is suspicious

Error Messages/Logs

agent_count: 1000, agents_done: 200, agents_error: 800, agents_skipped: 0, agents_empty_result: 0
subagent_tokens: 13,300,136, tool_uses: 3,926, duration_ms: 6,883,157 (~115 min)

[discover:0] blocked by safety classifier: Stage 2 classifier error - blocking based on stage 1 assessment
[discover:20]/[discover:21] handed row-id lists ["e"] / ["x"] — not real ids, flagged back by the sub-agent
[discover:206] ... [discover:999] failed: You've hit your session limit · resets 6:30pm (Asia/Tokyo)
parallel[1000] ... parallel[3824]+ failed: Workflow agent() call cap reached (1000). This usually means a
  loop using budget.remaining() never terminates because no token budget was set — remaining() returns
  Infinity when budget.total is null. Add a hard iteration cap to the loop, or pass a token budget.

Steps to Reproduce

const groups = Object.entries(args)
const results = await parallel(
groups.map(([name, ids]) => async () => {
return await agent(Your row ids (${ids.length}): ${JSON.stringify(ids)}, { label: 'discover:' + name })
}),
)

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.219

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Windows Terminal

Additional Information

_No response_

View original on GitHub ↗

3 Comments

IgorGanapolsky · 1 month ago

That 1000-agent fan-out from a string-vs-array args mixup is a nasty failure mode.

A few stopgaps that have helped on my side while the platform still accepts bad tool args:

  1. Fail closed before spawn: if the script/tool schema expects an object/array and you got a raw string, abort the agent fan-out path immediately — do not "recover" by spawning more workers.
  2. Hard cap concurrent subagents. Unlimited Task/agent spawn is what turns one bad parse into 13M tokens. Even a dumb wrapper that refuses spawn when N are already running is better than none.
  3. No-progress kill: if the same tool name + near-identical args fire k times with no file/tree change, terminate that session. Watching CPU alone is not enough; identical tool traces are the signal.

The attached workflow report is the clearest "platform must reject bad args before agent explosion" writeup I've seen this week. If you still have the session log of the first bad tool call (the string args), that single line is usually enough to reproduce.

COOLak · 1 month ago

Adding a related Billing Platform / cost-control signal, kept public-safe.

This report is a concrete version of a paid-customer risk that should not be treated as a normal usage event: a malformed or misinterpreted workflow input can fan out into hundreds or thousands of agent calls, burn paid quota / usage-credit budget, then report a completion shape that hides the catastrophic failure rate.

My direct unresolved case is on a different Claude billing surface: manual prepaid / bulk usage-credit purchases fail or fail to commit cleanly while automatic usage-credit reloads on the same paid billing setup continue charging successfully. The common owner boundary is the same: product runtime state, credit / allocation debits, support-visible account state, and customer remediation policy are not reconciled end-to-end.

Requested triage path: please route this issue family to a human Billing Platform / cost-control / agent-runtime owner with authority to inspect bad-args validation, agent fanout limits, non-retryable session-limit handling, token / credit debits, workflow completion semantics, and credit/cap restoration policy together.

Concrete guardrails that would protect paid users:

  • hard-stop agent fanout when parsed args are a string but the workflow expects an object or array;
  • enforce a default subagent/fanout cap even when a script has no explicit token budget;
  • stop scheduling further agents after a sustained run of non-retryable session-limit failures;
  • make completion summaries include the failure ratio, e.g. completed with 800/1000 agent calls failed;
  • expose enough per-workflow cost attribution for support to distinguish productive work from product/runtime-triggered burn;
  • publish a clear credit/cap restoration path when confirmed product behavior consumes paid quota without usable output.

Public, privacy-sanitized evidence hub for the related billing case:
https://coolak.github.io/anthropic-claude-billing-incident/

Billing reconciliation matrix / owner map:
https://coolak.github.io/anthropic-claude-billing-incident/reconciliation-matrix.html

I am intentionally not posting card details, bank names, private payment IDs, invoice IDs, support IDs, raw logs, screenshots, payment URLs, one-time codes, token values, or private support-thread text here.

kcarriedo · 17 days ago

The string-parsed-as-array -> 1000 agent fan-out is a specific instance of a wider problem: there is no control plane between "Claude decides to spawn agents" and "agents start consuming tokens." The validation and cap enforcement happen too late (or not at all when the root cause is a malformed argument).

A few things that would address the surface area of this report:

  1. Pre-spawn argument validation - if the tool schema says array and the model passes a string, reject before spawning, not after. The current behavior is to spawn agents over the malformed input and only fail partway through.
  1. A configurable hard cap below 1000 per workflow run. 1000 is a platform limit but most real workloads have a sensible upper bound of 5-20. Users should be able to set maxAgents in their workflow config and have violations surface as a pre-run warning, not a post-spend error.
  1. Real-time spend visibility during a run - a running token count per agent (or at least per workflow) so you can catch runaway fan-out while it is happening rather than after the quota is gone.

I build tooling for managing parallel Claude Code sessions and this failure mode (accidental fan-out due to malformed or misinterpreted tool input) comes up repeatedly. The cost asymmetry is severe: a single bad argument can cost more than a week of normal usage in under 4 minutes.

Disclosure: I build Claudiverse (https://claudiverse.ai), which addresses the monitoring side of this - but the pre-spawn validation is squarely a platform fix that should live upstream.