{"record":{"id":"0504410c59e26467","repo":"mastra-ai/mastra","slug":"resumestream-on-durableagent-requires-a-runid-in","errorCode":null,"errorMessage":"resumeStream() on DurableAgent requires a runId in streamOptions.","messagePattern":"resumeStream\\(\\) on DurableAgent requires a runId in streamOptions\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/agent/durable/durable-agent.ts","lineNumber":2551,"sourceCode":"      resourceId,\n      cleanup,\n      abort,\n    };\n  }\n\n  /**\n   * Override the inherited `resumeStream()` so that callers using the base\n   * `Agent` API (including `approveToolCall` / `declineToolCall`) are routed\n   * through the durable `resume()` path instead of the regular Agent's\n   * snapshot-based resume.\n   *\n   * Returns just the `MastraModelOutput` (matching the base Agent's return\n   * type) while internally delegating to `this.resume()`.\n   */\n  override async resumeStream(resumeData: any, streamOptions?: any): Promise<MastraModelOutput<TOutput>> {\n    const runId = streamOptions?.runId;\n    if (!runId) {\n      throw new Error('resumeStream() on DurableAgent requires a runId in streamOptions.');\n    }\n    const { runId: _runId, ...resumeOptions } = streamOptions;\n    const result = await this.resume(runId, resumeData, {\n      ...resumeOptions,\n      // Close the stream when the workflow re-suspends so the caller's\n      // `for await` loop terminates. Without this the stream stays open\n      // indefinitely when the resumed turn hits another suspend point.\n      [CLOSE_ON_SUSPEND]: true,\n    } as Parameters<DurableAgent<TAgentId, TTools, TOutput>['resume']>[2]);\n    return result.output;\n  }\n\n  /**\n   * Override the inherited `approveToolCall()` to route through the durable\n   * `resume()` path.\n   */\n  override async approveToolCall(\n    options: { runId: string; toolCallId?: string } & Record<string, any>,","sourceCodeStart":2533,"sourceCodeEnd":2569,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/agent/durable/durable-agent.ts#L2533-L2569","documentation":"DurableAgent.resumeStream() overrides the base Agent signature and requires the target runId to be supplied as streamOptions.runId (it resumes a persisted durable run, not an implicit one). If streamOptions is missing or has no runId, this plain Error is thrown at durable-agent.ts:2551.","triggerScenarios":"Calling agent.resumeStream(data) with no second argument; passing options without runId; migrating from base Agent code where resumeStream never needed an explicit runId; destructuring mistakes that drop the runId field.","commonSituations":"Migrating code written against the base Agent (where resumeStream needs no explicit runId) to DurableAgent; dropping runId via careless destructuring of streamOptions; calling resumeStream directly from UI code that only holds resumeData.","solutions":["Pass the runId explicitly: agent.resumeStream(resumeData, { runId }).","Reuse the runId captured from the original stream()/resume() result object.","If migrating from the base Agent, update call sites — the durable variant requires the extra option.","Use agent.resume(runId, data) if you need the full DurableAgentStreamResult rather than the stream output."],"exampleFix":"// before\nawait agent.resumeStream({ approved: true });\n// after\nawait agent.resumeStream({ approved: true }, { runId });","handlingStrategy":"validation","validationCode":"if (!streamOptions?.runId) throw new Error('runId required for resumeStream');","typeGuard":"function hasRunId(o: unknown): o is { runId: string } {\n  return typeof o === 'object' && o !== null && typeof (o as any).runId === 'string' && (o as any).runId.length > 0;\n}","tryCatchPattern":"try {\n  await agent.resumeStream(data, opts);\n} catch (e) {\n  if (String(e).includes('requires a runId in streamOptions')) {\n    // recover runId from your persistence or fail fast with a clear client error\n  } else throw e;\n}","preventionTips":["Thread the original runId through your request context.","Type resumeStream options to require runId at compile time.","Add a lint/unit test asserting resumeStream call sites include runId."],"tags":["durable-agent","resume-stream","arguments"],"backgroundTag":"missing-required-argument","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}