{"record":{"id":"9442897c4f3ccde1","repo":"mastra-ai/mastra","slug":"runid-is-required-to-stream-an-agent-builder-actio","errorCode":null,"errorMessage":"runId is required to stream an agent builder action","messagePattern":"runId is required to stream an agent builder action","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client-sdks/client-js/src/resources/agent-builder.ts","lineNumber":189,"sourceCode":"    const url = `/agent-builder/${this.actionId}/resume-async?${searchParams.toString()}`;\n    const result = await this.request(url, {\n      method: 'POST',\n      body: { ...resumeParams, requestContext },\n    });\n\n    return this.transformWorkflowResult(result);\n  }\n\n  /**\n   * Streams agent builder action progress in real-time.\n   * This calls `/agent-builder/:actionId/stream`.\n   */\n  async stream(\n    params: AgentBuilderActionRequest,\n    runId: string,\n  ): Promise<globalThis.ReadableStream<{ type: string; payload: any }>> {\n    if (!runId) {\n      throw new Error('runId is required to stream an agent builder action');\n    }\n\n    const searchParams = new URLSearchParams();\n    searchParams.set('runId', runId);\n\n    const requestContext = parseClientRequestContext(params.requestContext);\n    const { requestContext: _, ...actionParams } = params;\n\n    const url = `/agent-builder/${this.actionId}/stream?${searchParams.toString()}`;\n    const response: Response = await this.request(url, {\n      method: 'POST',\n      body: { ...actionParams, requestContext },\n      stream: true,\n    });\n\n    if (!response.ok) {\n      throw new Error(`Failed to stream agent builder action: ${response.statusText}`);\n    }","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/client-sdks/client-js/src/resources/agent-builder.ts#L171-L207","documentation":"AgentBuilder.stream() requires a runId to attach to the streaming request (sent as a runId query param) so server-side events can be correlated to the action run. An empty/undefined runId string is rejected before any network call.","triggerScenarios":"Calling agentBuilder.stream(params, runId) with runId === '' or undefined — e.g. passing a variable populated from a previous step that failed to produce a runId.","commonSituations":"Chaining create/run calls where the runId from the first response is lost or typed as optional; copy-pasted stream call used without first starting a run.","solutions":["Obtain a valid runId from the prior action/run response and pass it to stream().","If a run hasn't been started, invoke the non-streaming execute/run first to get a runId.","Validate runId is a non-empty string before calling stream()."],"exampleFix":"// before\nconst stream = await agentBuilder.stream(action, run?.id);\n// after\nif (!run?.id) throw new Error('No runId from run step');\nconst stream = await agentBuilder.stream(action, run.id);","handlingStrategy":"validation","validationCode":"function requireRunId(runId: string | undefined | null): string {\n  if (typeof runId !== 'string' || runId.length === 0) {\n    throw new Error('stream() requires a non-empty runId');\n  }\n  return runId;\n}","typeGuard":"function hasRunId(runId: unknown): runId is string {\n  return typeof runId === 'string' && runId.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Thread runId from the run-creation response through a required (non-optional) variable.","Guard chained create/run -> stream calls with a non-empty check.","Fail fast at the run step if no runId is produced."],"tags":["client","validation","streaming"],"backgroundTag":"missing-required-parameter","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}