{"record":{"id":"d16287d9ab3285af","repo":"mastra-ai/mastra","slug":"memory-error-resource-scoped-semantic-recall-is-e","errorCode":null,"errorMessage":"Memory error: Resource-scoped semantic recall is enabled but no resourceId was provided. Either provide a resourceId or explicitly set semanticRecall.scope to 'thread'.","messagePattern":"Memory error: Resource-scoped semantic recall is enabled but no resourceId was provided\\. Either provide a resourceId or explicitly set semanticRecall\\.scope to 'thread'\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/memory/src/index.ts","lineNumber":707,"sourceCode":"\n      const vectorConfig =\n        typeof config?.semanticRecall === `boolean`\n          ? {\n              topK: defaultTopK,\n              messageRange: defaultRange,\n            }\n          : {\n              topK: config?.semanticRecall?.topK ?? defaultTopK,\n              messageRange: config?.semanticRecall?.messageRange ?? defaultRange,\n            };\n\n      const resourceScope =\n        (typeof config?.semanticRecall === 'object' && config?.semanticRecall?.scope !== `thread`) ||\n        config.semanticRecall === true;\n\n      // Guard: If resource-scoped semantic recall is enabled but no resourceId is provided, throw an error\n      if (resourceScope && !resourceId && config?.semanticRecall && vectorSearchString) {\n        throw new Error(\n          `Memory error: Resource-scoped semantic recall is enabled but no resourceId was provided. ` +\n            `Either provide a resourceId or explicitly set semanticRecall.scope to 'thread'.`,\n        );\n      }\n\n      let usage: { tokens: number } | undefined;\n\n      // If history is disabled and there's no semantic recall to perform, return empty immediately\n      if (historyDisabledByConfig && (!config.semanticRecall || !vectorSearchString || !this.vector)) {\n        const result = {\n          messages: [],\n          usage: undefined,\n          total: 0,\n          page: page ?? 0,\n          perPage: 0,\n          hasMore: false,\n        };\n        span?.end({ output: { success: true }, attributes: { messageCount: 0 } });","sourceCodeStart":689,"sourceCodeEnd":725,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/memory/src/index.ts#L689-L725","documentation":"If semantic recall is enabled at resource scope (semanticRecall === true or an object with scope !== 'thread') and a vector search string is present but no resourceId was provided, recall cannot compute the resource_id filter and throws this guidance error instead of silently failing.","triggerScenarios":"memory.recall({ threadId }) with semanticRecall: true or { scope: 'resource' } and query text, but resourceId omitted; also agent memory config defaulting scope to 'resource' while caller passes only threadId.","commonSituations":"Upgrading Mastra where semanticRecall: true now implies resource scope; agent configs that changed scope defaults; code paths that always had resourceId removed in a refactor.","solutions":["Pass resourceId to recall()","Set semanticRecall: { scope: 'thread' } explicitly to keep thread-scoped recall when resourceId is unavailable","Update agent memory config so scope matches what callers actually provide"],"exampleFix":"// before\nawait memory.recall({ threadId, query: 'shipping status' });\n// after\nawait memory.recall({ threadId, resourceId, query: 'shipping status' });\n// or\nawait memory.recall({ threadId, query: 'shipping status', memoryConfig: { semanticRecall: { scope: 'thread' } } });","handlingStrategy":"validation","validationCode":"if (semanticRecallEnabledAtResourceScope && queryText && !resourceId) {\n  throw new Error('resourceId is required for resource-scoped semantic recall');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await memory.recall({ threadId, resourceId, query });\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Resource-scoped semantic recall is enabled but no resourceId')) {\n    // fall back to thread-scoped recall or surface a config error\n  } else throw e;\n}","preventionTips":["Always pass resourceId when semanticRecall is true (default scope is resource)","Explicitly set semanticRecall: { scope: 'thread' } if you only have threadId","Review scope semantics when upgrading Mastra versions"],"tags":["memory","semantic-recall","configuration","validation"],"backgroundTag":"missing-required-parameter","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}