{"record":{"id":"7fc4960e940c0786","repo":"mastra-ai/mastra","slug":"agent-send-stream-resume-missing-target","errorCode":"AGENT_SEND_STREAM_RESUME_MISSING_TARGET","errorMessage":"sendStreamResume() requires threadId, resourceId, and runId.","messagePattern":"sendStreamResume\\(\\) requires threadId, resourceId, and runId\\.","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/agent/agent.ts","lineNumber":9298,"sourceCode":"  ): Promise<MastraModelOutput<OUTPUT>> {\n    // Route standalone `new Agent({ durable: true })` calls through the\n    // durable execution path.\n    const durable = await this.#getStandaloneDurable();\n    if (durable) {\n      return durable.approveToolCall(options) as Promise<MastraModelOutput<OUTPUT>>;\n    }\n\n    // @ts-expect-error - the types here are wrong\n    return this.resumeStream({ approved: true }, options);\n  }\n\n  async sendStreamResume<OUTPUT = undefined>(\n    options: SendAgentStreamResumeOptions<OUTPUT>,\n  ): Promise<SendAgentStreamResumeResult> {\n    const { threadId, resourceId, runId, toolCallId, resumeData, streamOptions } = options;\n\n    if (!threadId || !resourceId || !runId) {\n      throw new MastraError({\n        id: 'AGENT_SEND_STREAM_RESUME_MISSING_TARGET',\n        domain: ErrorDomain.AGENT,\n        category: ErrorCategory.USER,\n        text: 'sendStreamResume() requires threadId, resourceId, and runId.',\n        details: { threadId, resourceId, runId, agentName: this.name },\n      });\n    }\n\n    const pubsub = this.getPubSub();\n    const hasLocalRun = agentThreadStreamRuntime.hasThreadRun(runId, pubsub);\n    let resumableRun = agentThreadStreamRuntime.getResumableThreadRun(\n      { threadId, resourceId, runId, toolCallId },\n      pubsub,\n    );\n\n    if (!resumableRun && !hasLocalRun) {\n      // The thread runtime only tracks runs seen by this process. Recover the\n      // explicitly targeted run from snapshot storage after a restart or when","sourceCodeStart":9280,"sourceCodeEnd":9316,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/agent/agent.ts#L9280-L9316","documentation":"A synchronous input-validation error from Agent.sendStreamResume(): the call is missing one or more of the required identifiers threadId, resourceId, or runId needed to locate the suspended stream run to resume. It is thrown before any storage lookup occurs.","triggerScenarios":"Calling agent.sendStreamResume({ threadId?: ..., resourceId?: ..., runId?: ... }) where any of threadId, resourceId, or runId is undefined/null/empty string.","commonSituations":"Destructuring resume parameters from a request handler where query/body fields are missing, forgetting to persist runId when the stream was suspended, UI passing partial resume options.","solutions":["Ensure threadId, resourceId, and runId are all provided in the options object","Verify the values are non-empty strings, not undefined from destructuring","Check that runId was captured from the original stream before suspension","Log the options object before the call to identify which field is missing"],"exampleFix":"// before\nawait agent.sendStreamResume({ threadId, resourceId }); // runId missing\n// after\nif (!runId) throw new Error('runId is required to resume');\nawait agent.sendStreamResume({ threadId, resourceId, runId, toolCallId, resumeData });","handlingStrategy":"validation","validationCode":"function canResume(o: { threadId?: string; resourceId?: string; runId?: string }): boolean {\n  return Boolean(o.threadId && o.resourceId && o.runId);\n}","typeGuard":"function isResumeTarget(o: Partial<{ threadId: string; resourceId: string; runId: string }>): o is { threadId: string; resourceId: string; runId: string } {\n  return typeof o.threadId === 'string' && o.threadId.length > 0\n    && typeof o.resourceId === 'string' && o.resourceId.length > 0\n    && typeof o.runId === 'string' && o.runId.length > 0;\n}","tryCatchPattern":"try {\n  await agent.sendStreamResume({ threadId, resourceId, runId });\n} catch (e) {\n  if (e instanceof MastraError && e.id === 'AGENT_SEND_STREAM_RESUME_MISSING_TARGET') {\n    logger.warn('resume aborted: missing identifiers', e.details);\n    return; // don't retry; fix the inputs\n  }\n  throw e;\n}","preventionTips":["Persist threadId, resourceId, and runId together when a stream suspends","Validate resume request payloads at the API boundary before calling the agent","Never destructure resume options without checking for undefined","Capture runId from the original stream lifecycle events, not user input"],"tags":["agent","streaming","validation","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}