{"record":{"id":"a65f9acd77c26efc","repo":"mastra-ai/mastra","slug":"processor-processor-id-sendstatesignal-could","errorCode":null,"errorMessage":"[Processor:${processor.id}] sendStateSignal could not load thread ${resolvedThreadId}","messagePattern":"\\[Processor:(.+?)\\] sendStateSignal could not load thread (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/processors/runner.ts","lineNumber":1594,"sourceCode":"          abortSignal: args.abortSignal,\n          agent: this.agent,\n          sendSignal: createProcessorSendSignal({ messageList, writer, rotateResponseMessageId }),\n          sendStateSignal: async (\n            stateSignal: AgentStateSignalInput | (Omit<AgentStateSignalInput, 'id'> & { id?: string }),\n          ) => {\n            const memoryContext = parseMemoryRequestContext(requestContext);\n            const resolvedMemory = args.memory;\n            const resolvedThreadId = args.threadId ?? memoryContext?.thread?.id;\n            const resolvedResourceId = args.resourceId ?? memoryContext?.resourceId;\n            if (!resolvedMemory || !resolvedThreadId || !resolvedResourceId) {\n              throw new Error(\n                `[Processor:${processor.id}] sendStateSignal requires Mastra memory with an active resourceId and threadId`,\n              );\n            }\n            const loadedThread =\n              (await resolvedMemory.getThreadById({ threadId: resolvedThreadId })) ?? memoryContext?.thread;\n            if (!loadedThread) {\n              throw new Error(`[Processor:${processor.id}] sendStateSignal could not load thread ${resolvedThreadId}`);\n            }\n            const thread = {\n              ...loadedThread,\n              id: resolvedThreadId,\n              resourceId: loadedThread.resourceId ?? resolvedResourceId,\n              createdAt: loadedThread.createdAt ?? new Date(),\n              updatedAt: loadedThread.updatedAt ?? new Date(),\n              metadata: loadedThread.metadata,\n            };\n            const result = await applyStateSignal({\n              input: stateSignal,\n              memory: resolvedMemory,\n              thread,\n              resourceId: resolvedResourceId,\n              threadId: resolvedThreadId,\n              memoryConfig: memoryContext?.memoryConfig,\n              messageList,\n              defaultId: processor.stateId ?? processor.id,","sourceCodeStart":1576,"sourceCodeEnd":1612,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/processors/runner.ts#L1576-L1612","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nawait agent.generate('hi', { memory: { thread: 'missing-thread', resource: 'u1' } });\n// after\nawait memory.createThread({ threadId: 'missing-thread', resourceId: 'u1' });\nawait agent.generate('hi', { memory: { thread: 'missing-thread', resource: 'u1' } });","handlingStrategy":"validation","validationCode":"// Ensure the thread exists before the run:\nconst thread = await memory.getThreadById({ threadId });\nif (!thread) await memory.createThread({ threadId, resourceId });","typeGuard":"async function threadExists(memory: Memory, threadId: string): Promise<boolean> {\n  return !!(await memory.getThreadById({ threadId }));\n}","tryCatchPattern":"try {\n  await agent.generate(input, { memory: { thread: threadId, resource: resourceId } });\n} catch (e) {\n  if (e instanceof Error && e.message.includes('could not load thread')) {\n    const tid = /thread (.+)$/.exec(e.message)?.[1];\n    console.error(`Thread ${tid} not found; create it via memory.createThread first`);\n  } else throw e;\n}","preventionTips":["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"],"tags":["agent","processors","memory","thread-not-found"],"backgroundTag":"memory-thread-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}