eyaltoledano/claude-task-master · error
Generated subtask ids must be sequential starting from 1
Error message
Generated subtask ids must be sequential starting from 1
What it means
The final check in ensureSequentialSubtaskIds(): after sorting the unique ids, they must form the sequence 1,2,3,... with no gaps. Ids like [1,3,4] or [2,3] fail. This guarantees subtask numbering is contiguous so future insertions and id-based references remain stable.
Source
Thrown at scripts/modules/task-manager/scope-adjustment.js:462
function ensureSequentialSubtaskIds(subtasks) {
if (!Array.isArray(subtasks) || subtasks.length === 0) {
return;
}
const ids = subtasks.map((subtask) => subtask.id);
if (ids.some((id) => !Number.isInteger(id) || id < 1)) {
throw new Error('Generated subtask ids must be positive integers');
}
const uniqueIds = new Set(ids);
if (uniqueIds.size !== ids.length) {
throw new Error('Generated subtasks must have unique ids');
}
const sortedIds = [...uniqueIds].sort((a, b) => a - b);
for (let index = 0; index < sortedIds.length; index += 1) {
if (sortedIds[index] !== index + 1) {
throw new Error(
'Generated subtask ids must be sequential starting from 1'
);
}
}
}
/**
* Generates AI prompt for scope adjustment
* @param {Object} task - The task to adjust
* @param {string} direction - 'up' or 'down'
* @param {string} strength - 'light', 'regular', or 'heavy'
* @param {string} customPrompt - Optional custom instructions
* @returns {string} The generated prompt
*/
function generateScopePrompt(task, direction, strength, customPrompt) {
const isUp = direction === 'up';
const strengthDescriptions = {
light: isUp ? 'minor enhancements' : 'slight simplifications',View on GitHub (pinned to c0c98d367c)
Solutions
- Retry the scope operation to get a properly sequenced generation.
- Renumber programmatically before persisting if you control the flow: subtasks.forEach((s, i) => { s.id = i + 1; }).
- Reinforce the prompt: 'number subtasks sequentially starting at 1 with no gaps' or provide a JSON schema example.
- Check whether a previous validation step removed a subtask and created the gap; fix the upstream filtering instead.
Example fix
// before
[{ "id": 1, "title": "a" }, { "id": 3, "title": "b" }]
// after (renumber)
subtasks.forEach((s, i) => { s.id = i + 1; });
// => [{ "id": 1, "title": "a" }, { "id": 2, "title": "b" }] Defensive patterns
Strategy: validation
Validate before calling
function idsAreSequentialFromOne(subtasks) {
const sorted = [...new Set(subtasks.map((s) => s.id))].sort((a, b) => a - b);
return sorted.every((id, i) => id === i + 1);
}
if (!idsAreSequentialFromOne(generated.subtasks)) {
generated.subtasks.forEach((s, i) => { s.id = i + 1; }); // renumber
} Type guard
function isSequentialInts(subtasks) {
const ids = subtasks.map((s) => s.id).sort((a, b) => a - b);
return ids.length > 0 && ids.every((id, i) => id === i + 1);
} Try / catch
try {
await scopeUpTask([taskId], strength);
} catch (err) {
if (err.message.includes('sequential starting from 1')) {
console.error('Subtask IDs had gaps or wrong start; renumber and retry');
} else throw err;
} Prevention
- Renumber subtask arrays to 1..n before passing them downstream
- Check upstream filters that may drop a subtask and create a gap
- Instruct the model to index from 1, not 0
- Validate the full 1..n sequence as part of your pre-write checks
When it happens
Trigger: scopeUpTask/scopeDownTask where the model outputs ids starting at 0, skips a number ([1,2,4]), starts at an arbitrary number ([3,4,5]), or returns more/fewer subtasks than ids suggest, leaving a gap after deduplication.
Common situations: Models that index from 0 (programming habit), partially valid responses where one subtask was dropped by a prior validation, or manual renumbering attempts in custom prompts.
Related errors
- Generated object does not match schema: ${validationError.me
- Generated subtask ids must be positive integers
- Generated subtasks must have unique ids
- MFA_VERIFICATION_FAILED
- Failed to initialize services: ${(error as Error).message}
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/94135030ef052fb1.
Report an issue: GitHub.