{"record":{"id":"49829edddf6e2569","repo":"ruvnet/ruflo","slug":"agent-this-id-is-not-available-status-this","errorCode":null,"errorMessage":"Agent ${this.id} is not available (status: ${this.status})","messagePattern":"Agent (.+?) is not available \\(status: (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/integration/src/agentic-flow-agent.ts","lineNumber":490,"sourceCode":"\n  /**\n   * Execute a task\n   *\n   * ADR-001: When agentic-flow is available, delegates task execution\n   * to agentic-flow's Agent.execute() which leverages:\n   * - Flash Attention for 2.49x-7.47x faster processing\n   * - SONA learning for real-time adaptation\n   * - AgentDB for 150x-12,500x faster memory retrieval\n   *\n   * @param task - Task to execute\n   * @returns Task result with output or error\n   */\n  async executeTask(task: Task): Promise<TaskResult> {\n    this.ensureInitialized();\n\n    // Validate agent is available\n    if (this.status === 'terminated' || this.status === 'error') {\n      throw new Error(`Agent ${this.id} is not available (status: ${this.status})`);\n    }\n\n    // Check concurrent task limit\n    if (this.currentTaskCount >= this.config.maxConcurrentTasks) {\n      throw new Error(`Agent ${this.id} has reached max concurrent tasks`);\n    }\n\n    this.currentTask = task;\n    this.currentTaskCount++;\n    this.status = 'busy';\n    this.taskStartTime = Date.now();\n    this.lastActivity = new Date();\n\n    this.emit('task-started', {\n      agentId: this.id,\n      taskId: task.id,\n      taskType: task.type,\n    });","sourceCodeStart":472,"sourceCodeEnd":508,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/integration/src/agentic-flow-agent.ts#L472-L508","documentation":"Thrown by AgenticFlowAgent#executeTask (v3/@claude-flow/integration/src/agentic-flow-agent.ts:490) when the agent's status is 'terminated' or 'error'. Dead or errored agents refuse new work so failures do not compound; the message embeds the offending status so you know which branch tripped.","triggerScenarios":"Calling executeTask after agent.terminate() or after a previous task put the agent into status 'error'; a swarm scheduler that has not yet replaced a crashed agent still dispatching to it; resuming a queue whose agent references were persisted past their lifetime.","commonSituations":"Reusing agent objects across test runs without re-initializing; error-handling code that swallows a prior failure and keeps the agent in the pool; long-lived pools where terminated agents are not evicted.","solutions":["Check agent.status (or a public availability getter) before dispatch and skip/recreate terminated or errored agents.","After any task failure, either call initialize() to recycle the agent or remove it from the pool and spawn a replacement.","In a scheduler loop, wrap dispatch in try/catch and treat this message as 'evict and respawn' rather than fatal.","Ensure terminate() is only called when the agent is being retired, and that nothing re-dispatches afterwards."],"exampleFix":"// before\nconst result = await agent.executeTask(task); // agent.status === 'terminated'\n\n// after\nif (agent.status === 'terminated' || agent.status === 'error') {\n  await agent.initialize(); // recycle, or replace the agent\n}\nconst result = await agent.executeTask(task);","handlingStrategy":"validation","validationCode":"const AVAIL = new Set(['idle', 'busy', 'initialized']);\nif (!AVAIL.has(agent.status) || agent.status === 'terminated' || agent.status === 'error') {\n  await agent.initialize(); // recycle or replace\n}","typeGuard":"function isAgentAvailable(a: { status: string }): boolean {\n  return a.status !== 'terminated' && a.status !== 'error';\n}","tryCatchPattern":"try {\n  return await agent.executeTask(task);\n} catch (e) {\n  if (/is not available \\(status:/.test((e as Error).message)) {\n    pool.evict(agent.id);\n    return pool.spawn().executeTask(task);\n  }\n  throw e;\n}","preventionTips":["Check status before dispatch and evict dead agents from pools immediately.","Recycle errored agents via initialize() or replace them — never leave them dispatchable.","After task failures, decide the agent's fate explicitly instead of leaving status 'error'."],"tags":["lifecycle","invalid-state","agent","task-dispatch"],"backgroundTag":"invalid-state-transition","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}