{"record":{"id":"b848cff245359ea9","repo":"mastra-ai/mastra","slug":"agent-send-stream-resume-no-suspended-thread-run","errorCode":"AGENT_SEND_STREAM_RESUME_NO_SUSPENDED_THREAD_RUN","errorMessage":"Agent \"${this.name}\" sendStreamResume() could not find a suspended run \"${runId}\" for thread \"${threadId}\".","messagePattern":"Agent \"(.+?)\" sendStreamResume\\(\\) could not find a suspended run \"(.+?)\" for thread \"(.+?)\"\\.","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/agent/agent.ts","lineNumber":9337,"sourceCode":"      try {\n        ({ runs: suspendedRuns } = await this.listSuspendedRuns({ threadId, resourceId }));\n      } catch (error) {\n        if (!(error instanceof MastraError) || error.id !== 'AGENT_LIST_SUSPENDED_RUNS_NO_STORAGE') {\n          throw error;\n        }\n      }\n\n      const storedRun = suspendedRuns.find(\n        run =>\n          run.runId === runId && (!toolCallId || run.toolCalls.some(toolCall => toolCall.toolCallId === toolCallId)),\n      );\n      if (storedRun) {\n        resumableRun = { runId, toolCallId };\n      }\n    }\n\n    if (!resumableRun) {\n      throw new MastraError({\n        id: 'AGENT_SEND_STREAM_RESUME_NO_SUSPENDED_THREAD_RUN',\n        domain: ErrorDomain.AGENT,\n        category: ErrorCategory.USER,\n        text: `Agent \"${this.name}\" sendStreamResume() could not find a suspended run \"${runId}\" for thread \"${threadId}\".`,\n        details: {\n          threadId,\n          resourceId,\n          runId,\n          agentName: this.name,\n        },\n      });\n    }\n\n    const resumeOptions = (streamOptions ?? {}) as AgentExecutionOptionsBase<unknown> & { toolCallId?: string };\n\n    await agentThreadStreamRuntime.queueStreamResume(\n      runId,\n      async () => {","sourceCodeStart":9319,"sourceCodeEnd":9355,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/agent/agent.ts#L9319-L9355","documentation":"Thrown by Agent.sendStreamResume() when the required identifiers were supplied but no suspended run matching the given runId (and optional toolCallId) could be found for the given threadId/resourceId in storage. The resume target does not exist or is no longer in a suspended/resumable state.","triggerScenarios":"Calling sendStreamResume() with a runId that was never suspended, already resumed/completed, purged from storage, or stored under a different threadId/resourceId than passed.","commonSituations":"Resuming after storage retention/cleanup removed the run, typo'd or stale runId from an old session, resuming a run that already completed, passing resourceId that differs from the one used when the run started.","solutions":["Verify the runId, threadId, and resourceId exactly match the original suspended run","Check storage (the agent's memory/storage adapter) for the run's current status before resuming","Handle already-resumed/completed runs idempotently in your app instead of resuming twice","Reduce storage retention or avoid manual cleanup of suspended runs","Persist runId/threadId/resourceId together when the stream suspends"],"exampleFix":"// before\nawait agent.sendStreamResume({ threadId, resourceId, runId }); // stale runId\n// after\nconst runs = await agent.listSuspendedStreamRuns({ threadId, resourceId });\nif (runs.includes(runId)) {\n  await agent.sendStreamResume({ threadId, resourceId, runId });\n}","handlingStrategy":"fallback","validationCode":"const suspended = await agent.listSuspendedStreamRuns({ threadId, resourceId });\nif (!suspended.includes(runId)) {\n  throw new Error(`run ${runId} is not suspended for thread ${threadId}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await agent.sendStreamResume({ threadId, resourceId, runId });\n} catch (e) {\n  if (e instanceof MastraError && e.id === 'AGENT_SEND_STREAM_RESUME_NO_SUSPENDED_THREAD_RUN') {\n    logger.warn('run not resumable; checking current state', { threadId, runId });\n    // fall back to inspecting run state or starting a new run\n  } else {\n    throw e;\n  }\n}","preventionTips":["Check the run is still suspended (via storage/list API) before resuming","Treat resume as idempotent: skip if the run already resumed or completed","Match threadId/resourceId exactly to those used when the run was created","Avoid letting storage retention purge runs that may still be resumed","Store runId, threadId, and resourceId as a triple in your application state"],"tags":["agent","streaming","resume","state-not-found"],"backgroundTag":"suspended-run-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}