{"record":{"id":"ccad1b04f7a578b7","repo":"ruvnet/ruflo","slug":"can-only-resume-paused-agent","errorCode":null,"errorMessage":"Can only resume paused agent","messagePattern":"Can only resume paused agent","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/swarm/src/domain/entities/agent.ts","lineNumber":205,"sourceCode":"  }\n\n  /**\n   * Pause the agent\n   */\n  pause(): void {\n    if (this._status !== 'active' && this._status !== 'busy') {\n      throw new Error('Can only pause active or busy agent');\n    }\n    this._status = 'paused';\n    this._updatedAt = new Date();\n  }\n\n  /**\n   * Resume paused agent\n   */\n  resume(): void {\n    if (this._status !== 'paused') {\n      throw new Error('Can only resume paused agent');\n    }\n    this._status = this._currentTaskIds.size > 0 ? 'busy' : 'active';\n    this._lastActiveAt = new Date();\n    this._updatedAt = new Date();\n  }\n\n  /**\n   * Terminate the agent\n   */\n  terminate(): void {\n    this._status = 'terminated';\n    this._currentTaskIds.clear();\n    this._updatedAt = new Date();\n  }\n\n  /**\n   * Mark agent as having an error\n   */","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/swarm/src/domain/entities/agent.ts#L187-L223","documentation":"Agent.resume() is only valid from the 'paused' state. This throw fires when resume() is called on an agent that is idle, active, busy, error, or terminated — i.e., there is nothing paused to resume.","triggerScenarios":"Calling resume() on a freshly created (idle) agent that was never started or paused Double resume() (second call sees 'active'/'busy')\nResuming an agent that errored while paused-adjacent workflows ran\nGeneric 'resume all' routines run after a crash where agents were never actually paused","commonSituations":"Startup scripts that call resume() on rehydrated agents regardless of persisted status UI resume controls not gated on the paused state\nCoordinator restart logic resuming agents that were stopped via terminate() instead of pause()","solutions":["Gate on agent.status === 'paused' before resume()\nIf the agent is 'idle', use start() instead; if 'error', use recover() then start()\nPersist the pre-shutdown state and replay the correct transition on boot\nMake resume idempotent in the calling layer"],"exampleFix":"// before\nagents.forEach(a => a.resume()); // throws for non-paused\n\n// after\nfor (const a of agents) {\n  if (a.status === 'paused') a.resume();\n  else if (a.status === 'idle') a.start();\n}","handlingStrategy":"type-guard","validationCode":"if (agent.status === 'paused') agent.resume();\nelse if (agent.status === 'idle') agent.start(); // common intent when people misuse resume()","typeGuard":"function isResumable(a) { return a.status === 'paused'; }","tryCatchPattern":"try { agent.resume(); }\ncatch (e) {\n  if (e instanceof Error && e.message === 'Can only resume paused agent') return;\n  throw e;\n}","preventionTips":["Gate resume controls on status === 'paused'","Persist pre-shutdown state so boot code replays the right transition (resume vs start)","Make lifecycle wrappers idempotent at the call site"],"tags":["agent","state-machine","lifecycle","domain-entity","typescript"],"backgroundTag":"state-machine-invalid-transition","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}