vercel/ai · error · Error
HarnessAgent: toTextStreamResponse is not implemented yet. T
Error message
HarnessAgent: toTextStreamResponse is not implemented yet. Track the foundation review for follow-up.
What it means
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.
Source
Thrown at packages/harness/src/agent/internal/harness-stream-text-result.ts:805
return createUIMessageStreamResponse({
stream: this.toUIMessageStream<UI_MESSAGE>({
originalMessages,
generateMessageId,
onEnd,
onFinish,
messageMetadata,
sendReasoning,
sendSources,
sendStart,
sendFinish,
onError,
}),
...init,
});
}
toTextStreamResponse(): never {
throw notSupportedYet('toTextStreamResponse');
}
// ─── Helpers ────────────────────────────────────────────────────────
private appendToCurrentStepContent(part: TextStreamPart<TOOLS>): void {
switch (part.type) {
case 'text-delta': {
// Coalesce contiguous text-deltas with the same id into one text part.
const last =
this.currentStepContent[this.currentStepContent.length - 1];
if (last && last.type === 'text') {
(last as { text: string }).text += part.text;
} else {
this.currentStepContent.push({
type: 'text',
text: part.text,
} as ContentPart<TOOLS>);
}View on GitHub (pinned to 69428b1f8b)
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.
Example fix
// before
const result = await agent.stream({ prompt });
return result.toTextStreamResponse();
// after
const result = await agent.stream({ prompt });
return new Response(result.textStream, {
headers: { 'content-type': 'text/plain; charset=utf-8' },
}); Defensive patterns
Strategy: fallback
Validate before calling
if (typeof result.toTextStreamResponse !== 'function' || isHarnessResult(result)) {
return new Response(result.textStream, { headers: { 'content-type': 'text/plain; charset=utf-8' } });
} Type guard
function supportsToTextStreamResponse(result: unknown): result is { toTextStreamResponse: (init?: ResponseInit) => Response } {
return typeof result === 'object' && result !== null &&
typeof (result as { toTextStreamResponse?: unknown }).toTextStreamResponse === 'function';
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- HarnessAgent: pipeTextStreamToResponse is not implemented ye
- Method not implemented.
- HarnessAgent: element streams in ${this.outputSpecification?
- 'element streams in no-schema mode' functionality not suppor
- 'element streams in object mode' functionality not supported
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/a5fd7273a2a94009.
Report an issue: GitHub.