{"record":{"id":"b841dc84b44aad66","repo":"mastra-ai/mastra","slug":"searchmessages-requires-a-vector-store-configure","errorCode":null,"errorMessage":"searchMessages requires a vector store. Configure vector and embedder on your Memory instance.","messagePattern":"searchMessages requires a vector store\\. Configure vector and embedder on your Memory instance\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/memory/src/index.ts","lineNumber":2236,"sourceCode":"    resourceId: string;\n    topK?: number;\n    filter?: {\n      threadId?: string;\n      observedAfter?: Date;\n      observedBefore?: Date;\n    };\n  }): Promise<{\n    results: Array<{\n      threadId: string;\n      score: number;\n      groupId?: string;\n      range?: string;\n      text?: string;\n      observedAt?: Date;\n    }>;\n  }> {\n    if (!this.vector) {\n      throw new Error('searchMessages requires a vector store. Configure vector and embedder on your Memory instance.');\n    }\n\n    const { embeddings, dimension } = await this.embedMessageContent(query);\n    const { indexName } = await this.createObservationEmbeddingIndex(dimension);\n\n    const vectorFilter: VectorFilter = { resource_id: resourceId };\n    if (filter?.threadId) {\n      vectorFilter.thread_id = filter.threadId;\n    }\n    if (filter?.observedAfter || filter?.observedBefore) {\n      vectorFilter.observed_at = {\n        ...(filter.observedAfter ? { $gt: filter.observedAfter.toISOString() } : {}),\n        ...(filter.observedBefore ? { $lt: filter.observedBefore.toISOString() } : {}),\n      };\n    }\n\n    const queryResults: Array<{\n      threadId: string;","sourceCodeStart":2218,"sourceCodeEnd":2254,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/memory/src/index.ts#L2218-L2254","documentation":"Memory.searchMessages() performs vector similarity search over stored messages, which requires both a vector store and an embedder. The library throws this error when the Memory instance was constructed without a `vector` store configured, so it cannot execute the semantic query.","triggerScenarios":"Calling memory.searchMessages(...) on a Memory instance created without passing a `vector` (and implicitly `embedder`) option; or constructing Memory with only a storage adapter.","commonSituations":"Upgrading from a setup that only used `storage` to semantic recall; copying Memory config from examples that omit vector store wiring; forgetting to instantiate an embedder (e.g. openai text-embedding model) alongside a vector DB (pgvector, Chroma, etc.).","solutions":["Construct Memory with both `vector` and `embedder` options (e.g. new Memory({ storage, vector: new PgVector(...), embedder: new FastEmbed() }))","If semantic search is not needed, use thread-level message retrieval APIs instead of searchMessages","Verify the Memory instance you are calling is the same configured one (not a second, unconfigured instance created elsewhere)"],"exampleFix":"// before\nconst memory = new Memory({ storage: new PostgresStore(...) });\nawait memory.searchMessages({ query, resourceId });\n\n// after\nconst memory = new Memory({\n  storage: new PostgresStore(...),\n  vector: new PgVector(process.env.DATABASE_URL),\n  embedder: new FastEmbed(),\n});\nawait memory.searchMessages({ query, resourceId });","handlingStrategy":"validation","validationCode":"function canSearchMessages(memory: Memory): boolean {\n  return !!(memory as any).vector;\n}\nif (!canSearchMessages(memory)) {\n  throw new Error('Configure vector and embedder on Memory before calling searchMessages');\n}","typeGuard":"function hasVectorStore(memory: Memory): memory is Memory & { vector: unknown } {\n  return Boolean((memory as any).vector);\n}","tryCatchPattern":"try {\n  await memory.searchMessages(args);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('requires a vector store')) {\n    return { messages: [] }; // semantic search unavailable; degrade gracefully\n  }\n  throw err;\n}","preventionTips":["Always configure `vector` and `embedder` together when instantiating Memory","Centralize Memory construction in one factory so vector config is never omitted","Add an early startup assertion that memory has a vector store if semantic search is a feature of your app"],"tags":["memory","vector-store","configuration","semantic-search"],"backgroundTag":"missing-vector-store-configuration","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}