ruvnet/ruflo · error
No available agents
Error message
No available agents
What it means
When orchestrateTask() is called without options.agentId, it scans the agents map for the first entry with status 'active' or 'idle' and throws 'No available agents' when none qualifies. Since spawnAgent() creates agents as 'active' and terminateAgent() marks them 'terminated' (without removing them), this error means: no agents spawned yet, or every spawned agent has been terminated.
Source
Thrown at v3/@claude-flow/plugins/src/integrations/agentic-flow.ts:316
/**
* Orchestrate a task.
*/
async orchestrateTask(options: TaskOrchestrationOptions): Promise<OrchestrationResult> {
if (!this.swarmInitialized) {
throw new Error('Swarm not initialized');
}
const taskId = `task-${this.nextTaskId++}`;
// Find or assign agent
let agentId = options.agentId;
if (!agentId) {
const availableAgent = Array.from(this.agents.values()).find(
a => a.status === 'active' || a.status === 'idle'
);
if (!availableAgent) {
throw new Error('No available agents');
}
agentId = availableAgent.id;
}
const result: OrchestrationResult = {
taskId,
status: 'running',
agentId,
startedAt: new Date(),
};
this.tasks.set(taskId, result);
this.emit(AGENTIC_FLOW_EVENTS.TASK_STARTED, {
taskId,
agentId,
taskType: options.taskType,
timestamp: new Date(),View on GitHub (pinned to fa13ee4ad6)
Solutions
- Spawn at least one agent before orchestrating, or pass options.agentId pointing at an existing active/idle agent
- Re-spawn replacement agents after terminating a pool before submitting more tasks
- Guard submission: check your own record of eligible agents before calling orchestrateTask without agentId
Example fix
// before
const result = await flow.orchestrateTask({ type: 'research' }); // Error: No available agents
// after
await flow.initializeSwarm({ type: 'mesh' });
await flow.spawnAgent({ type: 'researcher' });
const result = await flow.orchestrateTask({ type: 'research' }); Defensive patterns
Strategy: validation
Validate before calling
const live = new Map<string, SpawnedAgent>();
async function ensureWorker(): Promise<string> {
const eligible = [...live.values()].filter(a => a.status === 'active' || a.status === 'idle');
if (eligible.length === 0) {
const agent = await flow.spawnAgent({ type: 'coder' });
live.set(agent.id, agent);
return agent.id;
}
return eligible[0].id;
}
const result = await flow.orchestrateTask({ ...opts, agentId: await ensureWorker() }); Prevention
- Spawn the worker pool before submitting tasks
- Pass options.agentId when you track eligibility yourself
- Re-spawn replacements after terminating agents — terminated entries are never auto-selected
When it happens
Trigger: Orchestrating without agentId before spawning any agents; terminate-everything then submitting a task; agents all left in non-eligible statuses from earlier runs on the same instance.
Common situations: Boot scripts that submit seed tasks before spawning the worker pool; cleanup-all followed by continued task submission; tests that skip the spawn step.
Related errors
- Swarm not initialized
- Maximum agent limit (${this.config.maxConcurrentAgents}) rea
- Agent ${id} already exists
- Agent ${agentId} not found
- Max sessions (${this.config.maxSessions}) reached
AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18).
Data as JSON: /api/errors/d2814cd3d505ffd9.
Report an issue: GitHub.