eyaltoledano/claude-task-master · error · Error

Schema is required for object streaming

Error message

Schema is required for object streaming

What it means

BaseAIProvider.streamObject generates structured objects from a streaming model response and therefore requires a Zod/schema definition describing the object shape. If params.schema is missing/falsy after param and message validation pass, this error is thrown before any API call is made.

Source

Thrown at src/ai-providers/base-provider.js:434

				`${this.name} streamText initiated successfully for model: ${params.modelId}`
			);

			return stream;
		} catch (error) {
			this.handleError('text streaming', error);
		}
	}

	/**
	 * Streams a structured object using the provider's model
	 */
	async streamObject(params) {
		try {
			this.validateParams(params);
			this.validateMessages(params.messages);

			if (!params.schema) {
				throw new Error('Schema is required for object streaming');
			}

			log(
				'debug',
				`Streaming ${this.name} object with model: ${params.modelId}`
			);

			const client = await this.getClient(params);

			// Get Sentry telemetry config with function ID and metadata for better tracing
			// Format: provider.model.command.method
			const commandName = params.commandName || 'unknown';
			const functionId = `${this.name}.${params.modelId}.${commandName}.streamObject`;

			// Build telemetry metadata for enhanced filtering/grouping in Sentry
			const metadata = {
				command: commandName,
				outputType: params.outputType,

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Pass a valid schema (e.g. a Zod object schema) in the schema field of the params
  2. Verify the schema variable is defined before the call (log or assert it)
  3. If you don't need structured output, use streamText instead

Example fix

// before
await provider.streamObject({ modelId: 'x', messages });
// after
import { z } from 'zod';
await provider.streamObject({ modelId: 'x', messages, schema: z.object({ name: z.string() }) });
Defensive patterns

Strategy: validation

Validate before calling

function assertStreamObjectParams(params) {
  if (!params?.schema) throw new Error('streamObject requires params.schema (e.g. a z.object schema)');
}

Type guard

function hasSchema(params) {
  return typeof params === 'object' && params !== null && params.schema != null;
}

Try / catch

try {
  await provider.streamObject(params);
} catch (e) {
  if (e.message === 'Schema is required for object streaming') {
    console.error('params.schema missing; pass a Zod schema');
  } else throw e;
}

Prevention

When it happens

Trigger: Calling provider.streamObject({ modelId, messages }) without a schema property, or with schema set to null/undefined (e.g. a variable that failed to initialize).

Common situations: Conditionally building params and dropping the schema; migrating from a text-generation call to streamObject and forgetting the schema; dynamically imported schema module returning undefined.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29). Data as JSON: /api/errors/a7b29dfc4e67731a. Report an issue: GitHub.