vercel/ai · error · Error
HarnessAgent: element streams in ${this.outputSpecification?
Error message
HarnessAgent: element streams in ${this.outputSpecification?.name ?? 'text'} mode is not implemented yet. Track the foundation review for follow-up. What it means
HarnessAgent's elementStream getter only works when the agent has an outputSpecification that provides an element-stream transform (structured/object output modes). In plain text mode (or when the specification has no transform) accessing elementStream throws this explicit 'not implemented yet' error pointing to the foundation review tracker. It signals an unimplemented feature, not a misconfiguration bug.
Source
Thrown at packages/harness/src/agent/internal/harness-stream-text-result.ts:693
this.teeStream().pipeThrough(
new TransformStream<
EnrichedStreamPart<TOOLS, InferStreamOutput<OUTPUT>>,
InferStreamOutput<OUTPUT>
>({
transform({ partialOutput }, controller) {
if (partialOutput != null) {
controller.enqueue(partialOutput);
}
},
}),
),
) as AsyncIterableStream<InferStreamOutput<OUTPUT>>;
}
get elementStream(): AsyncIterableStream<InferElementOutput<OUTPUT>> {
const transform = this.outputSpecification?.createElementStreamTransform();
if (transform == null) {
throw notSupportedYet(
`element streams in ${this.outputSpecification?.name ?? 'text'} mode`,
);
}
return createAsyncIterableStream(
this.teeStream().pipeThrough(transform),
) as AsyncIterableStream<InferElementOutput<OUTPUT>>;
}
get output(): Promise<InferGenerateOutput<OUTPUT>> {
return this.finalStep.then(step => {
if (this.outputSpecification == null) {
throw notSupportedYet('structured output');
}
return this.outputSpecification.parseCompleteOutput(
{ text: step.text },
{
response: step.response,
usage: step.usage,View on GitHub (pinned to 69428b1f8b)
Solutions
- Don't use elementStream in text mode; iterate the textStream instead.
- Configure an outputSpecification that supports element streaming (e.g. an element/object output mode) before accessing elementStream.
- Check outputSpecification?.name before accessing; follow the linked foundation review for the feature landing.
Example fix
// before
for await (const el of result.elementStream) { ... }
// after
for await (const chunk of result.textStream) { ... } Defensive patterns
Strategy: fallback
Validate before calling
if (result.outputSpecification?.createElementStreamTransform() == null) {
// fall back to textStream instead of touching elementStream
} Try / catch
let elements;
try {
elements = result.elementStream;
} catch {
elements = null; // fall back to result.textStream
} Prevention
- Don't access elementStream unless the agent was configured with a schema/element output mode.
- Check outputSpecification before using structured streaming APIs.
- Prefer textStream in default text-mode agents.
When it happens
Trigger: Accessing result.elementStream on a HarnessStreamTextResult whose outputSpecification is null (text mode) or whose outputSpecification.createElementStreamTransform() returns null.
Common situations: Porting code from the core AI SDK's elementStream to a harness agent running in default text mode; expecting typed element chunks without configuring an output schema.
Related errors
- HarnessAgent: structured output is not implemented yet. Trac
- HarnessAgent: pipeUIMessageStreamToResponse is not implement
- Method not implemented.
- HarnessAgent: pipeTextStreamToResponse is not implemented ye
- HarnessAgent: toTextStreamResponse is not implemented yet. T
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/3f4eef379dbf9e8c.
Report an issue: GitHub.