v3/docs/adr/ADR-355-swarm-rl-stopping-policy.md
Status: Proposed Date: 2026-06-29 Authors: claude (dream-cycle agent, 2026-06-29) Related issues: dream-cycle #2026-06-29, arXiv 2605.02801
arXiv 2605.02801 (May 2026) surveys RL methods for LLM-based multi-agent orchestration and identifies five core sub-decisions: spawn timing, delegation, communication, aggregation, and stopping. After curating 84 papers, the authors find zero explicit RL training methods for the stopping decision. Every production system — LangGraph, AutoGen, CrewAI, OpenAI Swarm, and Ruflo — uses static stopping policies (token budgets, task completion signals, or hard agent-count caps).
Ruflo's current stopping mechanism is maxAgents: 8 (CLAUDE.md default) plus task completion. This cap is not learned; it does not adapt to task complexity, available resources, or quality signal from completed agents.
Implement an RL stopping-decision policy as a lightweight head on Ruflo's orchestrator. The policy observes:
hooks route output)And outputs a binary decision: spawn more agents or aggregate and stop.
Training source: Ruflo's existing post-task hook events become orchestration traces. Each swarm run produces a labeled trace (task → agents spawned → quality of final output). A simple bandit or REINFORCE head is trained offline on these traces.
Define orchestration trace schema (extends post-task hook payload):
{
"task_id": "...",
"complexity_score": 0.0–1.0,
"agents_spawned": [...],
"stopping_step": N,
"final_quality_score": 0.0–1.0
}
Add StoppingPolicyHead to @claude-flow/hooks workers (new stopping-policy worker, priority: normal).
Wire into swarm orchestrator: before each agent spawn, check policy; if stop=true, proceed to aggregation phase.
Start with a simple rule-based policy (threshold on complexity_score × agents_spawned) as a warm-start before RL training accumulates enough traces.
Expose via config: CLAUDE_FLOW_STOPPING_POLICY=rl|static|threshold (default: static to preserve existing behavior).
maxAgents=8 cap as a scaling constraint — policy naturally gates agent count.static — no behavior change until opt-in.docs/dream-cycle/2026-06-29-swarm.md