mastra-ai/mastra · error · Error
[Processor:${processor.id}] sendStateSignal could not load t
Error message
[Processor:${processor.id}] sendStateSignal could not load thread ${resolvedThreadId} What it means
After resolving memory/threadId/resourceId, sendStateSignal loads the thread via memory.getThreadById(); if no stored thread exists and none is present in the memory request context, this Error is thrown. The processor state cannot be attached to a non-existent thread.
Source
Thrown at packages/core/src/processors/runner.ts:1594
abortSignal: args.abortSignal,
agent: this.agent,
sendSignal: createProcessorSendSignal({ messageList, writer, rotateResponseMessageId }),
sendStateSignal: async (
stateSignal: AgentStateSignalInput | (Omit<AgentStateSignalInput, 'id'> & { id?: string }),
) => {
const memoryContext = parseMemoryRequestContext(requestContext);
const resolvedMemory = args.memory;
const resolvedThreadId = args.threadId ?? memoryContext?.thread?.id;
const resolvedResourceId = args.resourceId ?? memoryContext?.resourceId;
if (!resolvedMemory || !resolvedThreadId || !resolvedResourceId) {
throw new Error(
`[Processor:${processor.id}] sendStateSignal requires Mastra memory with an active resourceId and threadId`,
);
}
const loadedThread =
(await resolvedMemory.getThreadById({ threadId: resolvedThreadId })) ?? memoryContext?.thread;
if (!loadedThread) {
throw new Error(`[Processor:${processor.id}] sendStateSignal could not load thread ${resolvedThreadId}`);
}
const thread = {
...loadedThread,
id: resolvedThreadId,
resourceId: loadedThread.resourceId ?? resolvedResourceId,
createdAt: loadedThread.createdAt ?? new Date(),
updatedAt: loadedThread.updatedAt ?? new Date(),
metadata: loadedThread.metadata,
};
const result = await applyStateSignal({
input: stateSignal,
memory: resolvedMemory,
thread,
resourceId: resolvedResourceId,
threadId: resolvedThreadId,
memoryConfig: memoryContext?.memoryConfig,
messageList,
defaultId: processor.stateId ?? processor.id,View on GitHub (pinned to 75dd419e61)
Solutions
- Create the thread before the run (memory.createThread({ threadId, resourceId })) or run a prior turn so the thread exists.
- Verify the threadId is correct and points at an existing thread in the configured storage.
- Ensure resourceId matches the thread's owner; check storage backend connectivity if threads should exist.
Example fix
// before
await agent.generate('hi', { memory: { thread: 'missing-thread', resource: 'u1' } });
// after
await memory.createThread({ threadId: 'missing-thread', resourceId: 'u1' });
await agent.generate('hi', { memory: { thread: 'missing-thread', resource: 'u1' } }); Defensive patterns
Strategy: validation
Validate before calling
// Ensure the thread exists before the run:
const thread = await memory.getThreadById({ threadId });
if (!thread) await memory.createThread({ threadId, resourceId }); Type guard
async function threadExists(memory: Memory, threadId: string): Promise<boolean> {
return !!(await memory.getThreadById({ threadId }));
} Try / catch
try {
await agent.generate(input, { memory: { thread: threadId, resource: resourceId } });
} catch (e) {
if (e instanceof Error && e.message.includes('could not load thread')) {
const tid = /thread (.+)$/.exec(e.message)?.[1];
console.error(`Thread ${tid} not found; create it via memory.createThread first`);
} else throw e;
} Prevention
- Create threads (or run a first turn) before processors call sendStateSignal
- Validate threadIds against storage; avoid hardcoded/fabricated ids in tests
- Keep resourceId consistent with the thread's owner
- Watch for thread deletions that stateful processors still reference
When it happens
Trigger: sendStateSignal called with a threadId that was never created (no prior run created the thread), and no thread object available in the memory request context fallback.
Common situations: Typo'd or stale threadId; passing a brand-new thread id without letting memory create it first; deleting threads between runs while processors still reference them; tests using fabricated thread ids.
Related errors
- sendStateSignal could not load thread ${threadId}
- [Processor:${processor.id}] sendStateSignal requires Mastra
- Could not generate title from input ${JSON.stringify(message
- Received input message with wrong threadId. Input ${message.
- Received input message with wrong resourceId. Input ${messag
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/a65f9acd77c26efc.
Report an issue: GitHub.