{"record":{"id":"f1c0aade614cbe69","repo":"eyaltoledano/claude-task-master","slug":"failed-to-generate-tasks-using-generateobject-fall","errorCode":null,"errorMessage":"Failed to generate tasks using generateObject fallback","messagePattern":"Failed to generate tasks using generateObject fallback","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/parse-prd/parse-prd-streaming.js","lineNumber":620,"sourceCode":"\t\t\t\testimateTokens(JSON.stringify(tasks));\n\t\t\tconst inputTokens =\n\t\t\t\tresult.telemetryData?.inputTokens || context.estimatedInputTokens;\n\n\t\t\tcontext.progressTracker.updateTokens(inputTokens, outputTokens, false);\n\t\t}\n\n\t\treturn {\n\t\t\tparsedTasks: tasks.tasks,\n\t\t\testimatedOutputTokens:\n\t\t\t\tresult.telemetryData?.outputTokens ||\n\t\t\t\testimateTokens(JSON.stringify(tasks)),\n\t\t\tactualInputTokens: result.telemetryData?.inputTokens,\n\t\t\ttelemetryData: result.telemetryData,\n\t\t\tusedFallback: true\n\t\t};\n\t}\n\n\tthrow new Error('Failed to generate tasks using generateObject fallback');\n}\n\n/**\n * Prepare final result with cleanup\n */\nfunction prepareFinalResult(\n\tstreamingResult,\n\taiServiceResponse,\n\testimatedInputTokens,\n\tprogressTracker\n) {\n\tlet summary = null;\n\tif (progressTracker) {\n\t\tsummary = progressTracker.getSummary();\n\t\tprogressTracker.cleanup();\n\t}\n\n\t// If we have actual usage data from streaming, update the AI service response","sourceCodeStart":602,"sourceCodeEnd":638,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/parse-prd/parse-prd-streaming.js#L602-L638","documentation":"This error is thrown at the end of processWithGenerateObject in parse-prd-streaming.js when the AI SDK generateObject fallback could not produce a parseable tasks result. The streaming parse path first tries normal streaming; if that fails it retries with generateObject, and if that retry also returns nothing usable, this terminal error is raised.","triggerScenarios":"processStreamResponse falls back to processWithGenerateObject after a streaming failure, and the generateObject call throws, returns null/undefined result, or returns a result without tasks despite retrying.","commonSituations":"Invalid or unauthenticated API keys, AI provider outages or rate limits, PRD content too large for the model context, malformed PRD text producing schema-invalid output, network connectivity problems.","solutions":["Verify the AI provider API key is set and valid in your environment/mcp.json (e.g. ANTHROPIC_API_KEY / relevant provider key).","Check model availability and provider status; switch to a different configured model via --model or config.","Reduce the PRD size or lower num-tasks so output fits within context/token limits.","Check network/proxy connectivity to the AI provider endpoint.","Retry the parse-prd command; if persistent, run with debug logging to see the underlying generateObject failure."],"exampleFix":"// before\nnpx task-master parse-prd --input=huge-prd.md --num-tasks=50\n// after\nnpx task-master parse-prd --input=prd.md --num-tasks=10 --force","handlingStrategy":"retry","validationCode":"const apiKey = process.env.ANTHROPIC_API_KEY || providerKeyFromConfig;\nif (!apiKey) throw new Error('AI provider API key not configured');\nconst prdText = fs.readFileSync(prdPath, 'utf8');\nif (!prdText.trim()) throw new Error('PRD file is empty');\nif (prdText.length > 150000) throw new Error('PRD too large; split it before parsing');","typeGuard":"function hasTasksResult(r) {\n  return r != null && typeof r === 'object' &&\n    Array.isArray(r.tasks) && r.tasks.length > 0;\n}","tryCatchPattern":"try {\n  const result = await tmCore.tasks.parsePrd(prdPath, { numTasks: 10 });\n} catch (err) {\n  if (err.message.includes('Failed to generate tasks')) {\n    console.error('AI generation failed. Check API key, model availability, and PRD size.', { cause: err });\n    // optionally retry once with a smaller task count or fallback model\n  } else throw err;\n}","preventionTips":["Keep the AI provider API key configured and rotate before expiry.","Keep PRDs under a few hundred KB; split large documents.","Use a stable, widely available model rather than preview endpoints.","Handle transient AI failures with a bounded retry/backoff.","Test parse-prd on a small PRD before large runs."],"tags":["ai","parse-prd","streaming","fallback"],"backgroundTag":"ai-generation-failed","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}