P2 Token Incinerator — delegate_task Endless Recursive Loop (#52484)

Executive Summary

delegate_task has no max_depth parameter. When given an open-ended research prompt, the main agent spawns sub-agents, which spawn grandchild-agents, cascading into an endless sequential chain. A single travel search query triggered 44 sub-agent sessions over 53 minutes, consuming tokens exponentially. This is the 3rd distinct delegation subsystem bug we've tracked — joining #50199 (base_url ignored + results silently dropped) and #46303 (concurrent session cross-contamination). The delegation layer shows recurring containment failures.

Root Cause Analysis

1. No Recursion Depth Limit

Sub-agents have full capability to call delegate_task — no max_depth or allow_recursive: false toggle exists. Each spawned sub-agent is a fully capable agent that can itself spawn more agents, creating an unbounded tree.

2. Fallback Flaw When Pool Is at Capacity

When max_async_children (e.g., 3) is full, the fallback logic reverts to synchronous/sequential execution — but still spawns a brand new independent session for every single task, with no throttling or emergency abort mechanism.

Evidence from SQLite & Logs

MetricValue
Sub-agent sessions44
Duration53 minutes (16:31–17:24 CST)
Peak spawn rate8 sessions within a single minute (16:51)
Log flooddelegate_task: async pool at capacity (3 running)
Session evolutionCtrip → Xiaohongshu → Zhihu → Baidu (contextual, not duplicates)
Trigger Chain
User → Web UI → CLI agent → delegate_task → sub-agent 1 → sub-agent 1 also calls delegate_task → sub-agents 2, 3, 4... → infinite cascade until pool hits capacity (3 running) → falls back to synchronous mode, STILL spawns independent sessions

Impact Assessment

DimensionSeverityDetail
Token CostHIGHExponential token consumption — 44 sessions cascading from a single query
System StabilityHIGH8 sessions/minute peak; pool saturation, no abort mechanism
User ExperienceHIGH53-minute meltdown with no output; user receives nothing useful
ContainmentCRITICAL3rd delegation containment failure — systemic, not isolated

Proposed Fixes

  1. Add max_depth config — default to 3, hard-cap at a configurable limit
  2. Add allow_recursive: false toggle — sub-agents denied delegate_task by default
  3. Hard-block sub-agents from calling delegate_task when pool is saturated — no fallback spawning

PR: #52557 already open | Reporter willing to submit PR.

Delegation Subsystem Bug History

IssueSeverityDescription
#50199P2base_url ignored + results silently dropped
#46303P2Concurrent session cross-contamination
#52484P2Token Incinerator — endless recursive loop, no max depth

⚠️ Pattern: The delegation layer shows recurring containment failures across three distinct vectors. Each bug is a different failure mode — URL handling, session isolation, recursion depth — suggesting the delegation subsystem needs a fundamental redesign rather than point fixes.

Source Evidence

📋 https://hermes-agent.reviews/hermes-delegate-task-token-incinerator-52484.html
Tracked by hermes-agent.reviews — June 25, 2026