mastra-ai/mastra · error · Error

[Processor:${processor.id}] sendStateSignal requires Mastra

Error message

[Processor:${processor.id}] sendStateSignal requires Mastra memory with an active resourceId and threadId

What it means

A processor called the sendStateSignal() helper during processing, but the runner could not resolve all of: a Mastra memory instance, a resourceId, and a threadId (from args or the memory request context). sendStateSignal persists processor state into a memory thread, so all three are mandatory; a plain Error naming the processor is thrown.

Source

Thrown at packages/core/src/processors/runner.ts:1587

          ...inputData,
          state: processorState.customState,
          abort,
          ...(rotateResponseMessageId ? { rotateResponseMessageId } : {}),
          ...createObservabilityContext({ currentSpan: processorSpan }),
          retryCount: args.retryCount ?? 0,
          writer,
          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,

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Configure memory on the agent (new Memory({ storage })) and pass threadId + resourceId in the generate/stream call.
  2. Ensure the memory request context is available if relying on it for thread resolution.
  3. Remove or gate the sendStateSignal call in the processor when memory isn't guaranteed (check availability first).

Example fix

// before
await agent.generate('hi'); // processor calls sendStateSignal -> throws
// after
await agent.generate('hi', {
  memory: { thread: 'thread-123', resource: 'user-42' },
});
Defensive patterns

Strategy: validation

Validate before calling

function assertMemoryReady(args: { memory?: unknown; threadId?: string; resourceId?: string }) {
  if (!args.memory || !args.threadId || !args.resourceId)
    throw new Error('sendStateSignal processors require memory + threadId + resourceId in the agent call');
}
// call before agent.generate/stream
assertMemoryReady({ memory: agentMemory, threadId: 't-1', resourceId: 'u-1' });

Type guard

function hasMemoryContext(a: { memory?: unknown; threadId?: string; resourceId?: string }):
  a is { memory: NonNullable<typeof a.memory>; threadId: string; resourceId: string } {
  return !!a.memory && typeof a.threadId === 'string' && typeof a.resourceId === 'string';
}

Try / catch

try {
  await agent.generate(input, { memory: { thread, resource } });
} catch (e) {
  if (e instanceof Error && e.message.includes('sendStateSignal requires Mastra memory')) {
    console.error('Pass memory/threadId/resourceId to the agent call or disable stateful processors');
  } else throw e;
}

Prevention

When it happens

Trigger: A processor invokes sendStateSignal() in an agent configured without memory, or with memory but no threadId/resourceId supplied and no memory request context present.

Common situations: Using stateful processors in stateless/agent-as-tool setups; forgetting to pass threadId/resourceId to agent.generate; running agents without memory configured while a processor assumes it.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/44121ee735754c60. Report an issue: GitHub.