{"record":{"id":"6ca06b0cec09e8e3","repo":"mastra-ai/mastra","slug":"failed-to-stream-agent-builder-action-response","errorCode":null,"errorMessage":"Failed to stream agent builder action: ${response.statusText}","messagePattern":"Failed to stream agent builder action: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client-sdks/client-js/src/resources/agent-builder.ts","lineNumber":206,"sourceCode":"    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    }\n\n    if (!response.body) {\n      throw new Error('Response body is null');\n    }\n\n    return response.body.pipeThrough(this.createRecordParserTransform());\n  }\n\n  /**\n   * Observes an existing agent builder action run stream.\n   * Replays cached execution from the beginning, then continues with live stream.\n   * This is the recommended method for recovery after page refresh/hot reload.\n   * This calls `/agent-builder/:actionId/observe`\n   */\n  async observeStream(params: { runId: string }): Promise<globalThis.ReadableStream<{ type: string; payload: any }>> {\n    const searchParams = new URLSearchParams();\n    searchParams.set('runId', params.runId);","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/client-sdks/client-js/src/resources/agent-builder.ts#L188-L224","documentation":"The agent-builder stream POST returned a non-ok HTTP status. The client throws with only response.statusText, so the actual failure reason must be inferred from the status code and server logs.","triggerScenarios":"Calling agentBuilder.stream(action, runId) when the server rejects the request: invalid action params, bad requestContext, auth failure, runId not found, or server error during stream setup.","commonSituations":"Expired/missing credentials against the builder server; referencing a runId that no longer exists; sending action params that fail server-side validation (400).","solutions":["Check the numeric status (capture response.status in a wrapper, since this message only has statusText).","Verify authentication/credentials for the agent-builder API.","Confirm the runId exists server-side and the action params match AgentBuilderActionRequest schema.","Retry with backoff for 5xx statuses."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if (!runId) throw new Error('runId required before streaming');\nif (!params || typeof params !== 'object') throw new Error('action params required');","typeGuard":null,"tryCatchPattern":"try {\n  const stream = await agentBuilder.stream(action, runId);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Failed to stream agent builder action:')) {\n    // distinguish auth (401/403), validation (400), not-found runId (404), retry 5xx with backoff\n  }\n  throw e;\n}","preventionTips":["Validate action params against AgentBuilderActionRequest before sending.","Refresh credentials before long-running streaming sessions.","Verify the runId exists server-side and retry transient 5xx with backoff."],"tags":["network","http","streaming"],"backgroundTag":"http-request-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}