eyaltoledano/claude-task-master · error
streamObjectService requires a schema parameter
Error message
streamObjectService requires a schema parameter
What it means
A synchronous argument-validation error thrown at the top of streamObjectService. Streaming structured objects requires a Zod/JSON schema to validate and shape each streamed output, so calling without one is rejected before any client or API call is made.
Source
Thrown at scripts/modules/ai-services-unified.js:847
* Uses Vercel AI SDK's streamObject for proper JSON streaming.
*
* @param {object} params - Parameters for the service call.
* @param {string} params.role - The initial client role ('main', 'research', 'fallback').
* @param {object} [params.session=null] - Optional MCP session object.
* @param {string} [params.projectRoot=null] - Optional project root path for .env fallback.
* @param {import('zod').ZodSchema} params.schema - The Zod schema for the expected object.
* @param {string} params.prompt - The prompt for the AI.
* @param {string} [params.systemPrompt] - Optional system prompt.
* @param {string} params.commandName - Name of the command invoking the service.
* @param {string} [params.outputType='cli'] - 'cli' or 'mcp'.
* @returns {Promise<object>} Result object containing the stream and usage data.
*/
async function streamObjectService(params) {
const defaults = { outputType: 'cli' };
const combinedParams = { ...defaults, ...params };
// Stream object requires a schema
if (!combinedParams.schema) {
throw new Error('streamObjectService requires a schema parameter');
}
return _unifiedServiceRunner('streamObject', combinedParams);
}
/**
* Unified service function for generating structured objects.
* Handles client retrieval, retries, and fallback sequence.
*
* @param {object} params - Parameters for the service call.
* @param {string} params.role - The initial client role ('main', 'research', 'fallback').
* @param {object} [params.session=null] - Optional MCP session object.
* @param {string} [params.projectRoot=null] - Optional project root path for .env fallback.
* @param {import('zod').ZodSchema} params.schema - The Zod schema for the expected object.
* @param {string} params.prompt - The prompt for the AI.
* @param {string} [params.systemPrompt] - Optional system prompt.
* @param {string} [params.objectName='generated_object'] - Name for object/tool.
* @param {number} [params.maxRetries=3] - Max retries for object generation.
* @param {string} params.commandName - Name of the command invoking the service.View on GitHub (pinned to c0c98d367c)
Solutions
- Pass a schema: streamObjectService({ ..., schema: myZodObject }).
- Ensure the schema import is defined (not undefined) before the call.
- If you don't need structured output, use streamTextService instead.
- Wrap schema construction so defaults exist for the streaming path.
Example fix
// before
await streamObjectService({ role: 'main', prompt });
// after
await streamObjectService({ role: 'main', prompt, schema: TaskSchema }); Defensive patterns
Strategy: validation
Validate before calling
function assertSchema(schema) {
if (schema == null) throw new TypeError('streamObjectService: schema is required');
const isZod = typeof schema === 'object' && typeof schema.parse === 'function' && typeof schema.safeParse === 'function';
if (!isZod) throw new TypeError('streamObjectService: schema must be a Zod schema');
}
assertSchema(schema); Type guard
function isZodSchema(s) {
return s != null && typeof s === 'object' && typeof s.safeParse === 'function';
} Try / catch
if (!isZodSchema(schema)) {
throw new TypeError('A Zod schema is required before calling streamObjectService');
}
try {
await streamObjectService({ role: 'main', prompt, schema });
} catch (e) {
if (e.message.includes('requires a schema parameter')) return streamTextService({ role: 'main', prompt });
throw e;
} Prevention
- Always co-locate the schema with the streaming call in a single object literal.
- Type helpers so schema is a required parameter, catching omissions at compile time.
- Don't conditionally build params objects that can omit schema.
When it happens
Trigger: Calling streamObjectService({ ... }) where params omits the schema property — e.g. copying a generateTextService call and only renaming the function, or building params dynamically where schema is conditionally undefined.
Common situations: Refactoring from generateTextService to streaming without migrating the schema, passing a schema variable that is undefined due to a failed import or typo, or building a generic AI helper that only sometimes supplies a schema.
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
- Either existingTaskId or newSubtaskData must be provided
- Generated object does not match schema: ${validationError.me
- Invalid task ID format: "${trimmedId}". Expected format: "15
- Empty file path provided
- All tasks parameter must be an array
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/4497576fc2ec37a9.
Report an issue: GitHub.