{"record":{"id":"cae2963e002379a9","repo":"mastra-ai/mastra","slug":"sendstatesignal-requires-mastra-memory","errorCode":null,"errorMessage":"sendStateSignal requires Mastra memory","messagePattern":"sendStateSignal requires Mastra memory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/agent/thread-stream-runtime.ts","lineNumber":2716,"sourceCode":"  }\n\n  async sendStateSignal<OUTPUT = unknown>(\n    agent: Agent<any, any, any, any>,\n    stateInput: AgentStateSignalInput,\n    target: SendAgentStateSignalOptions<OUTPUT>,\n    pubsub?: PubSub,\n  ): Promise<SendAgentStateSignalResult<OUTPUT>> {\n    if (!target.resourceId || !target.threadId) {\n      throw new Error('resourceId and threadId are required to send a state signal');\n    }\n    const resourceId = target.resourceId;\n    const threadId = target.threadId;\n\n    const requestContext = target.ifIdle?.streamOptions?.requestContext;\n    const memoryContext = parseMemoryRequestContext(requestContext);\n    const memory = await agent.getMemory({ requestContext });\n    if (!memory) {\n      throw new Error('sendStateSignal requires Mastra memory');\n    }\n\n    const loadedThread = (await memory.getThreadById({ threadId })) ?? memoryContext?.thread;\n    if (!loadedThread) {\n      throw new Error(`sendStateSignal could not load thread ${threadId}`);\n    }\n\n    const thread = {\n      ...loadedThread,\n      id: threadId,\n      resourceId: loadedThread.resourceId ?? resourceId,\n      createdAt: loadedThread.createdAt ?? new Date(),\n      updatedAt: loadedThread.updatedAt ?? new Date(),\n      metadata: loadedThread.metadata,\n    };\n\n    const applied = await applyStateSignal({\n      input: stateInput,","sourceCodeStart":2698,"sourceCodeEnd":2734,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/agent/thread-stream-runtime.ts#L2698-L2734","documentation":"sendStateSignal() throws this when agent.getMemory() returns no memory instance. State signals are persisted through Mastra memory, so without a configured Memory the signal has nowhere to live and the runtime refuses to proceed.","triggerScenarios":"Calling sendStateSignal on an Agent constructed without a memory option (or whose memory factory resolves to undefined), even though resourceId/threadId were provided.","commonSituations":"Agent created for a stateless use case (no memory configured) later reused for signal-based workflows; memory passed via DI/environment config that failed to resolve; copy-pasting an agent definition without the memory block.","solutions":["Configure memory on the Agent: new Agent({ name, instructions, model, memory: new Memory({ storage, ... }) }).","Verify agent.getMemory({ requestContext }) resolves non-undefined in your setup (check DI/env wiring).","If the agent is intentionally stateless, use direct generate/stream instead of sendStateSignal."],"exampleFix":"// before\nconst agent = new Agent({ name: 'a', instructions: '...', model });\nawait runtime.sendStateSignal(agent, state, target); // throws\n// after\nconst agent = new Agent({ name: 'a', instructions: '...', model, memory: new Memory({ storage }) });\nawait runtime.sendStateSignal(agent, state, target);","handlingStrategy":"validation","validationCode":"const memory = await agent.getMemory({ requestContext });\nif (!memory) throw new Error('Agent has no memory; cannot sendStateSignal');","typeGuard":"function hasMemory(a: Agent): a is Agent & { getMemory(): Promise<Memory> } {\n  return Boolean(a.getMemory);\n} // plus an async check: (await a.getMemory({})) != null","tryCatchPattern":"try {\n  return await runtime.sendStateSignal(agent, state, target);\n} catch (e) {\n  if (e instanceof Error && e.message === 'sendStateSignal requires Mastra memory') {\n    // configure Memory on the agent or use a non-memory path\n  }\n  throw e;\n}","preventionTips":["Always configure memory on agents used in signal/state workflows","Smoke-test agent.getMemory() in app startup checks","Keep agent construction centralized so memory config can't be forgotten"],"tags":["agent","memory","configuration","signal"],"backgroundTag":"memory-not-configured","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}