eyaltoledano/claude-task-master · error
Received invalid task object from AI.
Error message
Received invalid task object from AI.
What it means
In full-update mode, updateTaskById takes the AI response's mainResult.task and merges it over the existing task. If the AI returned no task object (or a non-object), the code throws rather than writing garbage into tasks.json. It indicates the AI service response did not match the expected schema.
Source
Thrown at scripts/modules/task-manager/update-task-by-id.js:470
}
// Display AI usage telemetry for CLI users
if (outputFormat === 'text' && aiServiceResponse.telemetryData) {
displayAiUsageSummary(aiServiceResponse.telemetryData, 'cli');
}
// Return the updated task
return {
updatedTask: taskToUpdate,
telemetryData: aiServiceResponse.telemetryData,
tagInfo: aiServiceResponse.tagInfo
};
}
// Full update mode: Use structured data directly
const aiTask = aiServiceResponse.mainResult?.task;
if (!aiTask || typeof aiTask !== 'object')
throw new Error('Received invalid task object from AI.');
const updatedTask = {
...aiTask,
dependencies: aiTask.dependencies ?? [],
priority: aiTask.priority ?? null,
details: aiTask.details ?? null,
testStrategy: aiTask.testStrategy ?? null
};
if (!updatedTask.title || !updatedTask.description)
throw new Error('Updated task missing required fields.');
// Preserve ID if AI changed it
if (updatedTask.id !== taskId) {
report('warn', `AI changed task ID. Restoring original ID ${taskId}.`);
updatedTask.id = taskId;
}
// Preserve status if AI changed it
if (
updatedTask.status !== taskToUpdate.status &&View on GitHub (pinned to c0c98d367c)
Solutions
- Retry the update; transient AI failures often resolve on a second call
- Switch to a stronger model (e.g. the research model) via --research or provider config
- Reduce the size/complexity of the task details being sent
- Check the AI provider status/credentials if responses are consistently malformed
Defensive patterns
Strategy: type-guard
Type guard
function isAiTask(res) {
return !!res && typeof res === 'object' && !!res.mainResult &&
typeof res.mainResult.task === 'object' && res.mainResult.task !== null &&
typeof res.mainResult.task.title === 'string';
} Try / catch
try {
await updateTaskById(...);
} catch (e) {
if (e.message === 'Received invalid task object from AI.') {
// retry with stronger model / inspect raw response
} else throw e;
} Prevention
- Use capable models that honor structured JSON output
- Keep task payloads within model context limits
- Log raw AI responses in debug mode to diagnose schema drift
- Retry transient malformed responses
When it happens
Trigger: The AI provider returns a malformed/empty mainResult (e.g. truncated JSON, refusal message, wrong response shape) during update-task-by-id full update.
Common situations: Weak models returning prose instead of structured JSON, API errors surfaced as partial responses, very long tasks exceeding the model's output context, or misconfigured AI provider/baseURL returning an error payload.
Related errors
- Parsed AI response for updated tasks was not an array.
- Updated task missing required fields.
- ${result.message} || Update failed for task ${taskId}. The s
- File storage does not support updateTaskWithPrompt. Client-s
- File storage does not support expandTaskWithPrompt. Client-s
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/5f8bbc5c361ef092.
Report an issue: GitHub.