{"record":{"id":"a5fd7273a2a94009","repo":"vercel/ai","slug":"harnessagent-totextstreamresponse-is-not-implemen","errorCode":null,"errorMessage":"HarnessAgent: toTextStreamResponse is not implemented yet. Track the foundation review for follow-up.","messagePattern":"HarnessAgent: toTextStreamResponse is not implemented yet\\. Track the foundation review for follow-up\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/harness/src/agent/internal/harness-stream-text-result.ts","lineNumber":805,"sourceCode":"    return createUIMessageStreamResponse({\n      stream: this.toUIMessageStream<UI_MESSAGE>({\n        originalMessages,\n        generateMessageId,\n        onEnd,\n        onFinish,\n        messageMetadata,\n        sendReasoning,\n        sendSources,\n        sendStart,\n        sendFinish,\n        onError,\n      }),\n      ...init,\n    });\n  }\n\n  toTextStreamResponse(): never {\n    throw notSupportedYet('toTextStreamResponse');\n  }\n\n  // ─── Helpers ────────────────────────────────────────────────────────\n\n  private appendToCurrentStepContent(part: TextStreamPart<TOOLS>): void {\n    switch (part.type) {\n      case 'text-delta': {\n        // Coalesce contiguous text-deltas with the same id into one text part.\n        const last =\n          this.currentStepContent[this.currentStepContent.length - 1];\n        if (last && last.type === 'text') {\n          (last as { text: string }).text += part.text;\n        } else {\n          this.currentStepContent.push({\n            type: 'text',\n            text: part.text,\n          } as ContentPart<TOOLS>);\n        }","sourceCodeStart":787,"sourceCodeEnd":823,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/harness/src/agent/internal/harness-stream-text-result.ts#L787-L823","documentation":"toTextStreamResponse on HarnessStreamTextResult throws a notSupportedYet placeholder error because converting the harness agent's text stream into a standard HTTP Response has not been implemented. The library throws immediately to make the missing capability explicit during the foundation review rather than returning a broken response.","triggerScenarios":"Calling result.toTextStreamResponse() (with or without init options) on the result of a HarnessAgent streaming run; the method signature returns `never` because it always throws.","commonSituations":"Porting a route handler from `ai`'s streamText (where toTextStreamResponse is supported) to HarnessAgent; framework adapters (Next.js App Router, Remix) that expect a Response object; upgrading to the harness package and reusing old streaming response code.","solutions":["Construct the Response yourself from result.textStream: new Response(result.textStream, { headers: { 'content-type': 'text/plain; charset=utf-8', 'x-vercel-ai-ui-stream': undefined } }).","If you need UI message streaming, check whether toUIMessageStreamResponse (which is implemented) fits your use case instead.","Follow the harness foundation review for the upcoming implementation and update calls once available.","Fall back to core `ai` streamText for endpoints that require toTextStreamResponse semantics."],"exampleFix":"// before\nconst result = await agent.stream({ prompt });\nreturn result.toTextStreamResponse();\n// after\nconst result = await agent.stream({ prompt });\nreturn new Response(result.textStream, {\n  headers: { 'content-type': 'text/plain; charset=utf-8' },\n});","handlingStrategy":"fallback","validationCode":"if (typeof result.toTextStreamResponse !== 'function' || isHarnessResult(result)) {\n  return new Response(result.textStream, { headers: { 'content-type': 'text/plain; charset=utf-8' } });\n}","typeGuard":"function supportsToTextStreamResponse(result: unknown): result is { toTextStreamResponse: (init?: ResponseInit) => Response } {\n  return typeof result === 'object' && result !== null &&\n    typeof (result as { toTextStreamResponse?: unknown }).toTextStreamResponse === 'function';\n}","tryCatchPattern":null,"preventionTips":["Wrap harness results in an adapter that always constructs Responses from textStream instead of calling convenience methods.","Search codebase for toTextStreamResponse usages when migrating to the harness package.","Prefer toUIMessageStreamResponse (implemented) when serving UI clients.","Subscribe to harness package changelogs to learn when the method is implemented, then simplify."],"tags":["not-implemented","harness","streaming","http-response"],"backgroundTag":"method-not-implemented","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}