{"record":{"id":"3f4eef379dbf9e8c","repo":"vercel/ai","slug":"harnessagent-element-streams-in-this-outputspec","errorCode":null,"errorMessage":"HarnessAgent: element streams in ${this.outputSpecification?.name ?? 'text'} mode is not implemented yet. Track the foundation review for follow-up.","messagePattern":"HarnessAgent: element streams in (.+?) mode 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":693,"sourceCode":"      this.teeStream().pipeThrough(\n        new TransformStream<\n          EnrichedStreamPart<TOOLS, InferStreamOutput<OUTPUT>>,\n          InferStreamOutput<OUTPUT>\n        >({\n          transform({ partialOutput }, controller) {\n            if (partialOutput != null) {\n              controller.enqueue(partialOutput);\n            }\n          },\n        }),\n      ),\n    ) as AsyncIterableStream<InferStreamOutput<OUTPUT>>;\n  }\n\n  get elementStream(): AsyncIterableStream<InferElementOutput<OUTPUT>> {\n    const transform = this.outputSpecification?.createElementStreamTransform();\n    if (transform == null) {\n      throw notSupportedYet(\n        `element streams in ${this.outputSpecification?.name ?? 'text'} mode`,\n      );\n    }\n    return createAsyncIterableStream(\n      this.teeStream().pipeThrough(transform),\n    ) as AsyncIterableStream<InferElementOutput<OUTPUT>>;\n  }\n\n  get output(): Promise<InferGenerateOutput<OUTPUT>> {\n    return this.finalStep.then(step => {\n      if (this.outputSpecification == null) {\n        throw notSupportedYet('structured output');\n      }\n      return this.outputSpecification.parseCompleteOutput(\n        { text: step.text },\n        {\n          response: step.response,\n          usage: step.usage,","sourceCodeStart":675,"sourceCodeEnd":711,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/harness/src/agent/internal/harness-stream-text-result.ts#L675-L711","documentation":"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.","triggerScenarios":"Accessing result.elementStream on a HarnessStreamTextResult whose outputSpecification is null (text mode) or whose outputSpecification.createElementStreamTransform() returns null.","commonSituations":"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.","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."],"exampleFix":"// before\nfor await (const el of result.elementStream) { ... }\n// after\nfor await (const chunk of result.textStream) { ... }","handlingStrategy":"fallback","validationCode":"if (result.outputSpecification?.createElementStreamTransform() == null) {\n  // fall back to textStream instead of touching elementStream\n}","typeGuard":null,"tryCatchPattern":"let elements;\ntry {\n  elements = result.elementStream;\n} catch {\n  elements = null; // fall back to result.textStream\n}","preventionTips":["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."],"tags":["not-implemented","streaming","harness-agent","api-limitation"],"backgroundTag":"feature-not-implemented","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}