vercel/ai · error · Error

HarnessAgent: pipeTextStreamToResponse is not implemented ye

Error message

HarnessAgent: pipeTextStreamToResponse is not implemented yet. Track the foundation review for follow-up.

What it means

HarnessStreamTextResult.pipeTextStreamToResponse is a stub that intentionally throws because the harness package has not implemented HTTP Response piping for text streams. The SDK throws this eagerly so callers get a clear 'not supported yet' error instead of silent undefined behavior while the foundation is under review. It is a temporary placeholder, not an operational failure.

Source

Thrown at packages/harness/src/agent/internal/harness-stream-text-result.ts:767

        generateMessageId,
        onEnd,
        onFinish,
        messageMetadata,
        sendReasoning,
        sendSources,
        sendStart,
        sendFinish,
        onError,
      }),
    ) as AsyncIterableStream<InferUIMessageChunk<UI_MESSAGE>>;
  }

  pipeUIMessageStreamToResponse(): never {
    throw notSupportedYet('pipeUIMessageStreamToResponse');
  }

  pipeTextStreamToResponse(): never {
    throw notSupportedYet('pipeTextStreamToResponse');
  }

  toUIMessageStreamResponse<UI_MESSAGE extends UIMessage>({
    originalMessages,
    generateMessageId,
    onEnd,
    onFinish,
    messageMetadata,
    sendReasoning,
    sendSources,
    sendStart,
    sendFinish,
    onError,
    ...init
  }: ResponseInit & {
    consumeSseStream?: (options: {
      stream: ReadableStream<string>;
    }) => PromiseLike<void> | void;

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Do not call pipeTextStreamToResponse on HarnessStreamTextResult; read the stream yourself via result.textStream and build the Response manually (e.g. new Response(result.textStream, { headers: { 'content-type': 'text/plain; charset=utf-8' } })).
  2. Use toTextStreamResponse replacement pattern: pipe the textStream through a TransformStream into a Response in your route handler.
  3. Track the harness foundation review follow-up referenced in the error message and upgrade the package when the method ships.
  4. If you need full response piping today, use the core `ai` package streamText result instead of HarnessAgent for that endpoint.

Example fix

// before
const result = await agent.stream({ prompt });
return result.pipeTextStreamToResponse();
// 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 as any).pipeTextStreamToResponse !== 'function' || HarnessStreamTextResultNotImplemented) { /* use manual Response construction */ }

Type guard

function supportsPipeTextStream(result: unknown): boolean {
  return typeof result === 'object' && result !== null &&
    typeof (result as { pipeTextStreamToResponse?: unknown }).pipeTextStreamToResponse === 'function';
}

Prevention

When it happens

Trigger: Calling result.pipeTextStreamToResponse() on the object returned by a HarnessAgent streamText run in packages/harness; every invocation throws immediately since the method body is `throw notSupportedYet('pipeTextStreamToResponse')`.

Common situations: Migrating server code that used the standard AI SDK StreamTextResult (e.g. a Next.js route returning the response) to a harness-based agent; copying examples built on streamText from `ai` and running them against HarnessAgent before checking the harness API surface.

Related errors


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/418d80de2da5d9b9. Report an issue: GitHub.