{"record":{"id":"40de72a0863a2862","repo":"vercel/ai","slug":"element-streams-in-no-schema-mode-functionality","errorCode":null,"errorMessage":"'element streams in no-schema mode' functionality not supported.","messagePattern":"'element streams in no-schema mode' functionality not supported\\.","errorType":"exception","errorClass":"UnsupportedFunctionalityError","httpStatus":null,"severity":"error","filePath":"packages/ai/src/generate-object/output-strategy.ts","lineNumber":97,"sourceCode":"      finishReason: FinishReason;\n    },\n  ): Promise<ValidationResult<JSONValue>> {\n    return value === undefined\n      ? {\n          success: false,\n          error: new NoObjectGeneratedError({\n            message: 'No object generated: response did not match schema.',\n            text: context.text,\n            response: context.response,\n            usage: context.usage,\n            finishReason: context.finishReason,\n          }),\n        }\n      : { success: true, value };\n  },\n\n  createElementStream() {\n    throw new UnsupportedFunctionalityError({\n      functionality: 'element streams in no-schema mode',\n    });\n  },\n};\n\nconst objectOutputStrategy = <OBJECT>(\n  schema: Schema<OBJECT>,\n): OutputStrategy<DeepPartial<OBJECT>, OBJECT, never> => ({\n  type: 'object',\n  jsonSchema: async () => await schema.jsonSchema,\n\n  async validatePartialResult({ value, textDelta }) {\n    return {\n      success: true,\n      value: {\n        // Note: currently no validation of partial results:\n        partial: value as DeepPartial<OBJECT>,\n        textDelta,","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/ai/src/generate-object/output-strategy.ts#L79-L115","documentation":"This UnsupportedFunctionalityError is thrown by the no-schema output strategy when code asks for an element stream (`elementStream` on a streamObject result). Element streaming — emitting individual validated array elements as they complete — is only implemented for `output: 'array'` mode, so the no-schema strategy deliberately refuses it. The library throws early rather than silently returning an empty or undefined stream.","triggerScenarios":"Calling `streamObject({ output: 'no-schema', ... })` and then consuming `result.elementStream`. TypeScript usually prevents this at compile time, but it occurs when types are cast/erased (e.g. `as any`), when result objects are passed through untyped wrappers, or when running older JS that bypasses the type system.","commonSituations":"Developers migrating from `output: 'array'` to `output: 'no-schema'` (to skip schema validation) but still consuming `elementStream`; dynamic code that selects output mode at runtime while always reading `elementStream`; loosely typed JavaScript callers.","solutions":["Switch to `output: 'array'` with an element schema if you need `elementStream`.","Consume `partialObjectStream` or `textStream` instead of `elementStream` when using `output: 'no-schema'`.","Remove `as any` / untyped wrappers so TypeScript's type on the streamObject result prevents accessing `elementStream` in no-schema mode."],"exampleFix":"// before\nconst result = streamObject({ model, prompt, output: 'no-schema' });\nfor await (const element of result.elementStream) { ... }\n\n// after\nconst result = streamObject({ model, prompt, output: 'array', schema: z.object({ name: z.string() }) });\nfor await (const element of result.elementStream) { ... }","handlingStrategy":"type-guard","validationCode":"// check mode before touching elementStream\nfunction supportsElementStream(result: unknown): boolean {\n  return typeof result === 'object' && result !== null && 'elementStream' in result;\n}\n// only call streamObject with output:'array' if you plan to read elementStream","typeGuard":"function isArrayModeOutput(output: unknown): output is 'array' {\n  return output === 'array';\n}","tryCatchPattern":"try {\n  for await (const el of result.elementStream) { /* ... */ }\n} catch (e) {\n  if (UnsupportedFunctionalityError.isInstance(e)) {\n    // fall back to result.partialObjectStream or textStream\n  } else throw e;\n}","preventionTips":["Only access elementStream when output is 'array'.","Never cast streamObject options/results with `as any`.","In generic streaming helpers, branch on the output mode.","Prefer partialObjectStream/textStream for no-schema mode."],"tags":["streaming","no-schema","unsupported-functionality","api-misuse"],"backgroundTag":"unsupported-functionality-error","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}