mastra-ai/mastra · error
Part index ${partIndex} not found in message ${cursor}. Avai
Error message
Part index ${partIndex} not found in message ${cursor}. Available indices: ${availableIndices} What it means
High-detail recall fetches a specific `partIndex` within the cursor message. When no formatted part matches the requested index (and no next-message fallback applies because the requested index isn't beyond the highest visible one, or no next message exists), it throws listing the valid indices. Indices correspond to formatted visible parts, not raw content array positions.
Source
Thrown at packages/memory/src/tools/om-tools.ts:857
? `To continue this part, call recall cursor="${cursor}" partIndex=${partIndex} detail="high" charOffset=${fallbackChunk.nextCharOffset}.`
: undefined;
return {
text: fallbackChunk.text,
messageId: firstNextPart.messageId,
partIndex: firstNextPart.partIndex,
role: firstNextPart.role,
type: firstNextPart.type,
truncated: fallbackChunk.truncated,
charOffset: fallbackChunk.charOffset,
nextCharOffset: fallbackChunk.nextCharOffset,
note: fallbackContinuation,
};
}
}
}
throw new Error(`Part index ${partIndex} not found in message ${cursor}. Available indices: ${availableIndices}`);
}
const chunk = chunkTextByTokens(target.text, maxTokens, charOffset);
const note = chunk.nextCharOffset
? `To continue this part, call recall cursor="${target.messageId}" partIndex=${target.partIndex} detail="high" charOffset=${chunk.nextCharOffset}.`
: undefined;
return {
text: chunk.text,
messageId: target.messageId,
partIndex: target.partIndex,
role: target.role,
type: target.type,
truncated: chunk.truncated,
charOffset: chunk.charOffset,
nextCharOffset: chunk.nextCharOffset,
note,
};View on GitHub (pinned to 75dd419e61)
Solutions
- Read the error's 'Available indices' list and retry with one of those exact partIndex values.
- If you need content after this message, re-run paged recall for the next messages instead of guessing partIndex.
- Re-fetch the message's parts (detail="high") to get current indices before continuing; don't reuse stale continuation notes.
- Remember indices are the formatted visible part indices — verify against the current response, not an older one.
Example fix
// before
// stale note said partIndex=3, but message was compacted
await recallDetail({ memory, threadId, cursor, partIndex: 3 });
// after
try {
await recallDetail({ memory, threadId, cursor, partIndex: 3 });
} catch (e) {
const m = /Available indices: ([\d, ]+)/.exec(e.message);
const idx = Number(m?.[1]?.split(',')[0]?.trim() ?? 0);
await recallDetail({ memory, threadId, cursor, partIndex: idx });
} Defensive patterns
Strategy: retry
Validate before calling
// Parse available indices from a prior failure before retrying
const available = /Available indices: ([\d, ]+)/.exec(lastError?.message ?? '')
?.[1]?.split(',').map(s => Number(s.trim())) ?? [];
if (available.length && !available.includes(partIndex)) partIndex = available[0]; Try / catch
try {
return await recallDetail({ memory, threadId, cursor, partIndex });
} catch (e) {
const m = e instanceof Error && /Available indices: ([\d, ]+)/.exec(e.message);
if (m) {
const fallback = Number(m[1].split(',')[0].trim());
return recallDetail({ memory, threadId, cursor, partIndex: fallback });
}
throw e;
} Prevention
- Always reuse partIndex values exactly as returned in the latest response's continuation note.
- Re-fetch parts (detail="high") after any memory processing/trim before continuing pagination.
- Cap agent retry loops so they parse 'Available indices' instead of incrementing blindly.
When it happens
Trigger: Requesting partIndex larger than the number of parts in a message that isn't the last message (so the next-message fallback can't apply); partIndex negative; stale continuation note referencing a partIndex from a message whose parts changed (e.g. after memory processing/trimming); misreading zero-based vs one-based indexing.
Common situations: Model blindly re-calls with partIndex from a previous message's note after the cursor changed; messages compacted by observational-memory between calls, shrinking the part list; agent retry loops incrementing partIndex past the end.
Related errors
- GitHub cursor must be a positive page number.
- Invalid knowledge node cursor.
- Knowledge node cursor does not match the active browse filte
- Cursor is required
- Could not resolve cursor message: ${cursor}
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/318e4a9bbf5ffee6.
Report an issue: GitHub.