@mastra/memory 1.26.1-alpha.0 → 1.26.1-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18980,9 +18980,10 @@ async function listThreadsForResource({ memory, resourceId, currentThreadId, pag
18980
18980
  hasMore
18981
18981
  };
18982
18982
  }
18983
+ const SEARCH_NOT_CONFIGURED_MESSAGE = "Search is not configured. Enable it with `retrieval: { vector: true }` and configure a vector store and embedder on your Memory instance.";
18983
18984
  async function searchMessagesForResource({ memory, resourceId, currentThreadId, query, topK = 10, maxTokens = DEFAULT_MAX_RESULT_TOKENS, before, after, threadScope }) {
18984
18985
  if (!memory.searchMessages) return {
18985
- results: "Search is not configured. Enable it with `retrieval: { vector: true }` and configure a vector store and embedder on your Memory instance.",
18986
+ results: SEARCH_NOT_CONFIGURED_MESSAGE,
18986
18987
  count: 0
18987
18988
  };
18988
18989
  const MAX_TOPK = 20;
@@ -19528,9 +19529,16 @@ async function recallThreadFromStart({ memory, threadId, resourceId, page = 1, l
19528
19529
  }
19529
19530
  const recallTool = (_memoryConfig, options) => {
19530
19531
  const isResourceScope = (options?.retrievalScope ?? "thread") === "resource";
19532
+ const searchEnabled = options?.searchEnabled ?? true;
19533
+ const description = isResourceScope ? `Browse conversation history. Use mode="threads" to list all threads for the current user. Use mode="messages" (default) to browse messages in the current thread or pass threadId to browse another thread in the active resource. When mode="messages" has no cursor or threadId, it defaults to the current thread and says so at the top of the result. If you pass only a cursor, it must belong to the current thread.${searchEnabled ? " Use mode=\"search\" to find messages by content across all threads." : ""}` : `Browse conversation history in the current thread. Use mode="messages" (default) to page through messages near a cursor.${searchEnabled ? " Use mode=\"search\" to find messages by content in this thread." : ""} Use mode="threads" to get the current thread's ID and title.`;
19534
+ const modeEnum = searchEnabled ? [
19535
+ "messages",
19536
+ "threads",
19537
+ "search"
19538
+ ] : ["messages", "threads"];
19531
19539
  return (0, _mastra_core_tools.createTool)({
19532
19540
  id: "recall",
19533
- description: isResourceScope ? "Browse conversation history. Use mode=\"threads\" to list all threads for the current user. Use mode=\"messages\" (default) to browse messages in the current thread or pass threadId to browse another thread in the active resource. When mode=\"messages\" has no cursor or threadId, it defaults to the current thread and says so at the top of the result. If you pass only a cursor, it must belong to the current thread. Use mode=\"search\" to find messages by content across all threads." : "Browse conversation history in the current thread. Use mode=\"messages\" (default) to page through messages near a cursor. Use mode=\"search\" to find messages by content in this thread. Use mode=\"threads\" to get the current thread's ID and title.",
19541
+ description,
19534
19542
  inputSchema: {
19535
19543
  $schema: "http://json-schema.org/draft-07/schema#",
19536
19544
  type: "object",
@@ -19538,12 +19546,8 @@ const recallTool = (_memoryConfig, options) => {
19538
19546
  ...isResourceScope ? {
19539
19547
  mode: {
19540
19548
  type: "string",
19541
- enum: [
19542
- "messages",
19543
- "threads",
19544
- "search"
19545
- ],
19546
- description: "What to retrieve. \"messages\" (default) pages through message history. \"threads\" lists all threads for the current user. \"search\" finds messages by semantic similarity across all threads."
19549
+ enum: modeEnum,
19550
+ description: `What to retrieve. "messages" (default) pages through message history. "threads" lists all threads for the current user.${searchEnabled ? " \"search\" finds messages by semantic similarity across all threads." : ""}`
19547
19551
  },
19548
19552
  threadId: {
19549
19553
  type: "string",
@@ -19560,18 +19564,14 @@ const recallTool = (_memoryConfig, options) => {
19560
19564
  }
19561
19565
  } : { mode: {
19562
19566
  type: "string",
19563
- enum: [
19564
- "messages",
19565
- "threads",
19566
- "search"
19567
- ],
19568
- description: "What to retrieve. \"messages\" (default) pages through message history. \"threads\" returns info about the current thread. \"search\" finds messages by semantic similarity in this thread."
19567
+ enum: modeEnum,
19568
+ description: `What to retrieve. "messages" (default) pages through message history. "threads" returns info about the current thread.${searchEnabled ? " \"search\" finds messages by semantic similarity in this thread." : ""}`
19569
19569
  } },
19570
- query: {
19570
+ ...searchEnabled ? { query: {
19571
19571
  type: "string",
19572
19572
  minLength: 1,
19573
19573
  description: "Search query for mode=\"search\". Finds messages semantically similar to this text."
19574
- },
19574
+ } } : {},
19575
19575
  cursor: {
19576
19576
  type: "string",
19577
19577
  minLength: 1,
@@ -19632,6 +19632,10 @@ const recallTool = (_memoryConfig, options) => {
19632
19632
  if (!memory) throw new Error("Memory instance is required for recall");
19633
19633
  if (explicitThreadId === "current" && !currentThreadId) throw new Error("Could not resolve current thread.");
19634
19634
  if (mode === "search") {
19635
+ if (!searchEnabled) return {
19636
+ results: SEARCH_NOT_CONFIGURED_MESSAGE,
19637
+ count: 0
19638
+ };
19635
19639
  if (!query) throw new Error("query is required for mode=\"search\"");
19636
19640
  if (!resourceId) throw new Error("Resource ID is required for recall");
19637
19641
  return searchMessagesForResource({
@@ -20593,6 +20597,24 @@ function getUnobservedPartsPreservingToolCallPairs(message) {
20593
20597
  return preservedCalls.length > 0 ? [...preservedCalls, ...unobservedParts] : unobservedParts;
20594
20598
  }
20595
20599
  /**
20600
+ * Get the messages Observational Memory is allowed to work with.
20601
+ *
20602
+ * Messages supplied through the `context` option are per-run ephemeral input. Core's
20603
+ * persistence contract already treats them as never-persist: `MessageStateManager` routes
20604
+ * them into `userContextMessages`, and `drainUnsavedMessages` only drains input/response.
20605
+ *
20606
+ * OM builds its windows from `get.all.db()`, which includes context messages, and then
20607
+ * seals and persists candidates directly — turning ephemeral context into durable user
20608
+ * messages. Excluding them here keeps OM's window, sealing, persistence and token
20609
+ * accounting consistent with that contract.
20610
+ */
20611
+ function getObservableMessages(messageList) {
20612
+ const allMessages = messageList.get.all.db();
20613
+ const contextMessageIds = messageList.makeMessageSourceChecker().context;
20614
+ if (contextMessageIds.size === 0) return allMessages;
20615
+ return allMessages.filter((message) => !contextMessageIds.has(message.id));
20616
+ }
20617
+ /**
20596
20618
  * Safely extract buffered observation chunks from a record.
20597
20619
  * Handles both array and JSON-string formats, returning empty array if malformed.
20598
20620
  */
@@ -20605,7 +20627,7 @@ function getUnobservedPartsPreservingToolCallPairs(message) {
20605
20627
  */
20606
20628
  function filterObservedMessages(opts) {
20607
20629
  const { messageList, record } = opts;
20608
- const allMessages = messageList.get.all.db();
20630
+ const allMessages = getObservableMessages(messageList);
20609
20631
  const useMarkerBoundaryPruning = opts.useMarkerBoundaryPruning ?? true;
20610
20632
  const preserveMessageIds = opts.preserveMessageIds ?? /* @__PURE__ */ new Set();
20611
20633
  const observedIds = new Set(Array.isArray(record?.observedMessageIds) ? record.observedMessageIds : []);
@@ -21158,7 +21180,7 @@ var ObservationStrategy = class ObservationStrategy {
21158
21180
  */
21159
21181
  async persistMarkerToMessage(marker, messageList, threadId, resourceId) {
21160
21182
  if (!messageList) return false;
21161
- const allMsgs = messageList.get.all.db();
21183
+ const allMsgs = getObservableMessages(messageList);
21162
21184
  for (let i = allMsgs.length - 1; i >= 0; i--) {
21163
21185
  const msg = allMsgs[i];
21164
21186
  if (msg?.role === "assistant" && msg.content?.parts && Array.isArray(msg.content.parts)) {
@@ -22037,7 +22059,7 @@ var ObservationStep = class {
22037
22059
  let didThresholdCleanup = false;
22038
22060
  let observerExchange;
22039
22061
  if (this.stepNumber === 0) {
22040
- const step0Messages = messageList.get.all.db();
22062
+ const step0Messages = getObservableMessages(messageList);
22041
22063
  const activation = await om.activate({
22042
22064
  threadId,
22043
22065
  resourceId,
@@ -22069,7 +22091,7 @@ var ObservationStep = class {
22069
22091
  currentModel: this.turn.actorModelContext,
22070
22092
  requestContext: this.turn.requestContext,
22071
22093
  observabilityContext: this.turn.observabilityContext,
22072
- lastActivityAt: getLastActivityFromMessages(messageList.get.all.db()),
22094
+ lastActivityAt: getLastActivityFromMessages(getObservableMessages(messageList)),
22073
22095
  reflectionHooks: om.composeHooks(void 0, {
22074
22096
  threadId,
22075
22097
  resourceId,
@@ -22079,7 +22101,7 @@ var ObservationStep = class {
22079
22101
  await this.turn.refreshRecord();
22080
22102
  if (this.turn.record.generationCount > preReflectGeneration) reflected = true;
22081
22103
  }
22082
- const allMsgsForToolCheck = messageList.get.all.db();
22104
+ const allMsgsForToolCheck = getObservableMessages(messageList);
22083
22105
  const lastMessage = allMsgsForToolCheck[allMsgsForToolCheck.length - 1];
22084
22106
  const pendingStepMessages = [...messageList.get.input.db(), ...messageList.get.response.db()];
22085
22107
  const latestStepParts = [...getLatestStepParts(lastMessage?.content?.parts ?? []), ...pendingStepMessages.flatMap((msg) => getLatestStepParts(msg.content?.parts ?? []))];
@@ -22088,10 +22110,10 @@ var ObservationStep = class {
22088
22110
  let statusSnapshot = await om.getStatus({
22089
22111
  threadId,
22090
22112
  resourceId,
22091
- messages: messageList.get.all.db()
22113
+ messages: getObservableMessages(messageList)
22092
22114
  });
22093
22115
  if (statusSnapshot.shouldBuffer && !hasIncompleteToolCalls) {
22094
- const allMessages = messageList.get.all.db();
22116
+ const allMessages = getObservableMessages(messageList);
22095
22117
  const unobservedMessages = om.getUnobservedMessages(allMessages, statusSnapshot.record);
22096
22118
  const candidates = om.getUnobservedMessages(unobservedMessages, statusSnapshot.record, { excludeBuffered: true });
22097
22119
  if (candidates.length > 0) {
@@ -22183,7 +22205,7 @@ var ObservationStep = class {
22183
22205
  statusSnapshot = await om.getStatus({
22184
22206
  threadId,
22185
22207
  resourceId,
22186
- messages: messageList.get.all.db()
22208
+ messages: getObservableMessages(messageList)
22187
22209
  });
22188
22210
  }
22189
22211
  const otherThreadsContext = await this.turn.refreshOtherThreadsContext();
@@ -22232,7 +22254,7 @@ var ObservationStep = class {
22232
22254
  const { threadId, resourceId, messageList } = this.turn;
22233
22255
  const om = this.turn.om;
22234
22256
  await om.waitForBuffering(threadId, resourceId);
22235
- const observableMessages = this.seededResponseMessage ? messageList.get.all.db().filter((msg) => msg.id !== this.turn.responseMessageId) : messageList.get.all.db();
22257
+ const observableMessages = this.seededResponseMessage ? getObservableMessages(messageList).filter((msg) => msg.id !== this.turn.responseMessageId) : getObservableMessages(messageList);
22236
22258
  const freshStatus = await om.getStatus({
22237
22259
  threadId,
22238
22260
  resourceId,
@@ -22262,7 +22284,7 @@ var ObservationStep = class {
22262
22284
  currentModel: this.turn.actorModelContext,
22263
22285
  requestContext: this.turn.requestContext,
22264
22286
  observabilityContext: this.turn.observabilityContext,
22265
- lastActivityAt: getLastActivityFromMessages(messageList.get.all.db()),
22287
+ lastActivityAt: getLastActivityFromMessages(getObservableMessages(messageList)),
22266
22288
  reflectionHooks: om.composeHooks(void 0, {
22267
22289
  threadId,
22268
22290
  resourceId,
@@ -22288,7 +22310,7 @@ var ObservationStep = class {
22288
22310
  });
22289
22311
  if (obsResult.observed) {
22290
22312
  const observedMessageIds = new Set(obsResult.record.observedMessageIds ?? []);
22291
- const liveMessages = messageList.get.all.db();
22313
+ const liveMessages = getObservableMessages(messageList);
22292
22314
  let latestObservedIndex = -1;
22293
22315
  for (let i = liveMessages.length - 1; i >= 0; i--) {
22294
22316
  const message = liveMessages[i];
@@ -22463,7 +22485,7 @@ var ObservationTurn = class {
22463
22485
  const asyncObservationEnabled = this.om.buffering.isAsyncObservationEnabled();
22464
22486
  const bufferOnIdle = this.om.getObservationConfig().bufferOnIdle;
22465
22487
  if (asyncObservationEnabled && bufferOnIdle) {
22466
- const allMessages = this.messageList.get.all.db();
22488
+ const allMessages = getObservableMessages(this.messageList);
22467
22489
  const record = this._record;
22468
22490
  const unobservedMessages = this.om.getUnobservedMessages(allMessages, record);
22469
22491
  if (unobservedMessages.length > 0) this.om.buffer({
@@ -22833,7 +22855,7 @@ function getCurrentModel$1(model) {
22833
22855
  return formatModelContext$1(model?.provider, model?.modelId);
22834
22856
  }
22835
22857
  function getLastModelFromMessageList(messageList) {
22836
- const messages = messageList?.get.all.db();
22858
+ const messages = messageList ? getObservableMessages(messageList) : void 0;
22837
22859
  if (!messages) return void 0;
22838
22860
  for (let i = messages.length - 1; i >= 0; i--) {
22839
22861
  const message = messages[i];
@@ -24417,7 +24439,7 @@ var ObservationalMemory = class ObservationalMemory {
24417
24439
  */
24418
24440
  async persistMarkerToMessage(marker, messageList, threadId, resourceId) {
24419
24441
  if (!messageList) return;
24420
- const allMsgs = messageList.get.all.db();
24442
+ const allMsgs = getObservableMessages(messageList);
24421
24443
  for (let i = allMsgs.length - 1; i >= 0; i--) {
24422
24444
  const msg = allMsgs[i];
24423
24445
  if (msg?.role === "assistant" && msg.content?.parts && Array.isArray(msg.content.parts)) {
@@ -25095,7 +25117,7 @@ ${formattedMessages}
25095
25117
  async cleanupMessages(opts) {
25096
25118
  const { threadId, resourceId, observedMessageIds, retentionFloor, preserveMessageIds } = opts;
25097
25119
  const messageList = this.isMessageList(opts.messages) ? opts.messages : void 0;
25098
- const allMsgs = messageList ? messageList.get.all.db() : opts.messages;
25120
+ const allMsgs = messageList ? getObservableMessages(messageList) : opts.messages;
25099
25121
  let markerIdx = -1;
25100
25122
  let markerMsg = null;
25101
25123
  for (let i = allMsgs.length - 1; i >= 0; i--) {
@@ -26211,7 +26233,7 @@ function isTemporalGapMarkerForMessage(message, targetMessageId) {
26211
26233
  async function insertTemporalGapMarkers({ messageList, sendSignal }) {
26212
26234
  const latestInputMessage = messageList.get.input.db().filter((message) => Boolean(message)).at(-1);
26213
26235
  if (!latestInputMessage || isTemporalGapMarker(latestInputMessage)) return;
26214
- const allMessages = messageList.get.all.db().filter((message) => Boolean(message));
26236
+ const allMessages = getObservableMessages(messageList).filter((message) => Boolean(message));
26215
26237
  const latestInputIndex = allMessages.findIndex((message) => message.id === latestInputMessage.id);
26216
26238
  if (latestInputIndex <= 0) return;
26217
26239
  if (allMessages.some((message) => isTemporalGapMarkerForMessage(message, latestInputMessage.id))) return;
@@ -26435,7 +26457,7 @@ var ObservationalMemoryProcessor = class {
26435
26457
  threadId,
26436
26458
  resourceId
26437
26459
  });
26438
- const allDbMsgs = messageList.get.all.db();
26460
+ const allDbMsgs = getObservableMessages(messageList);
26439
26461
  const tokenCounter = this.engine.getTokenCounter();
26440
26462
  const contextTokens = await tokenCounter.countMessagesAsync(allDbMsgs);
26441
26463
  const otherThreadsContext = this.turn.context.otherThreadsContext;
@@ -26805,6 +26827,18 @@ var Memory = class extends _mastra_core_memory.MastraMemory {
26805
26827
  _omEngine;
26806
26828
  _omEngineInstance;
26807
26829
  _mastraInstance;
26830
+ /**
26831
+ * Every vector cleanup that deleteThread or deleteMessages started in the background.
26832
+ * Callers do not wait for the cleanup, so this handle is the only join point.
26833
+ */
26834
+ pendingVectorCleanup = Promise.resolve();
26835
+ /**
26836
+ * Adds a background vector cleanup to the join handle.
26837
+ * The handle keeps the earlier cleanups, so it settles only after all of them end.
26838
+ */
26839
+ trackVectorCleanup(cleanup) {
26840
+ this.pendingVectorCleanup = Promise.allSettled([this.pendingVectorCleanup, cleanup]).then(() => void 0);
26841
+ }
26808
26842
  /** The shared ObservationalMemory engine. Lazily created on first access. */
26809
26843
  get omEngine() {
26810
26844
  if (!this._omEngine) this._omEngine = this._initOMEngine().then((engine) => {
@@ -27069,26 +27103,40 @@ var Memory = class extends _mastra_core_memory.MastraMemory {
27069
27103
  const thread = await memoryStore.getThreadById({ threadId });
27070
27104
  await memoryStore.deleteThread({ threadId });
27071
27105
  if (thread?.resourceId && memoryStore.supportsObservationalMemory) await memoryStore.clearObservationalMemory(threadId, thread.resourceId);
27072
- if (this.vector) this.deleteThreadVectors(threadId);
27106
+ if (this.vector) this.trackVectorCleanup(this.deleteThreadVectors(threadId));
27073
27107
  }
27074
27108
  /**
27075
- * Lists all vector indexes that match the memory messages prefix.
27076
- * Handles separator differences across vector store backends (e.g. '_' vs '-').
27109
+ * Prefix shared by every message index. The index for the default embedding
27110
+ * dimension is named with the bare prefix; other dimensions add a suffix.
27077
27111
  */
27078
- async getMemoryVectorIndexes() {
27112
+ get messageIndexPrefix() {
27113
+ return this.getEmbeddingIndexName();
27114
+ }
27115
+ /**
27116
+ * Prefix shared by every observation index. Each observation index adds a dimension suffix.
27117
+ */
27118
+ get observationIndexPrefix() {
27119
+ return `memory${this.vector?.indexSeparator ?? "_"}observations`;
27120
+ }
27121
+ /**
27122
+ * Lists the vector indexes whose name starts with one of the given prefixes.
27123
+ * Index names can carry a dimension suffix, so discovery matches on the prefix.
27124
+ */
27125
+ async getMemoryVectorIndexes(prefixes) {
27079
27126
  if (!this.vector) return [];
27080
- const prefix = `memory${this.vector.indexSeparator ?? "_"}messages`;
27081
- return (await this.vector.listIndexes()).filter((name) => name.startsWith(prefix));
27127
+ return (await this.vector.listIndexes()).filter((name) => prefixes.some((prefix) => name.startsWith(prefix)));
27082
27128
  }
27083
27129
  /**
27084
27130
  * Deletes all vector embeddings associated with a thread.
27085
27131
  * This is called internally by deleteThread to clean up orphaned vectors.
27132
+ * Both message and observation vectors are removed, so no text of the deleted
27133
+ * thread stays reachable through resource-scoped retrieval.
27086
27134
  *
27087
27135
  * @param threadId - The ID of the thread whose vectors should be deleted
27088
27136
  */
27089
27137
  async deleteThreadVectors(threadId) {
27090
27138
  try {
27091
- const memoryIndexes = await this.getMemoryVectorIndexes();
27139
+ const memoryIndexes = await this.getMemoryVectorIndexes([this.messageIndexPrefix, this.observationIndexPrefix]);
27092
27140
  await Promise.all(memoryIndexes.map(async (indexName) => {
27093
27141
  try {
27094
27142
  await this.vector.deleteVectors({
@@ -27096,14 +27144,14 @@ var Memory = class extends _mastra_core_memory.MastraMemory {
27096
27144
  filter: { thread_id: threadId }
27097
27145
  });
27098
27146
  } catch {
27099
- this.logger.debug("Failed to delete vectors for thread, skipping", {
27147
+ this.logger.warn("Failed to delete vectors of the deleted thread from index", {
27100
27148
  threadId,
27101
27149
  indexName
27102
27150
  });
27103
27151
  }
27104
27152
  }));
27105
27153
  } catch {
27106
- this.logger.debug("Failed to clean up vectors for thread", { threadId });
27154
+ this.logger.warn("Failed to clean up vectors of the deleted thread", { threadId });
27107
27155
  }
27108
27156
  }
27109
27157
  async updateWorkingMemory({ threadId, resourceId, workingMemory, memoryConfig, observabilityContext }) {
@@ -27776,7 +27824,7 @@ Notes:
27776
27824
  getObservationEmbeddingIndexName(dimensions) {
27777
27825
  const usedDimensions = dimensions ?? 384;
27778
27826
  const separator = this.vector?.indexSeparator ?? "_";
27779
- return `memory${separator}observations${separator}${usedDimensions}`;
27827
+ return `${this.observationIndexPrefix}${separator}${usedDimensions}`;
27780
27828
  }
27781
27829
  async createObservationEmbeddingIndex(dimensions) {
27782
27830
  const usedDimensions = dimensions ?? 384;
@@ -28022,7 +28070,10 @@ Notes:
28022
28070
  tools[name] = tool;
28023
28071
  }
28024
28072
  const omConfig = normalizeObservationalMemoryConfig(mergedConfig.observationalMemory);
28025
- if (omConfig?.retrieval) tools.recall = recallTool(mergedConfig, { retrievalScope: typeof omConfig.retrieval === "object" ? omConfig.retrieval.scope ?? "resource" : "resource" });
28073
+ if (omConfig?.retrieval) tools.recall = recallTool(mergedConfig, {
28074
+ retrievalScope: typeof omConfig.retrieval === "object" ? omConfig.retrieval.scope ?? "resource" : "resource",
28075
+ searchEnabled: this.hasRetrievalSearch(omConfig.retrieval)
28076
+ });
28026
28077
  return tools;
28027
28078
  }
28028
28079
  /**
@@ -28078,7 +28129,7 @@ Notes:
28078
28129
  }));
28079
28130
  const messageIdsNeedingDeletion = /* @__PURE__ */ new Set([...messageIdsWithClearedContent, ...messageIdsWithNewEmbeddings]);
28080
28131
  if (messageIdsNeedingDeletion.size > 0) try {
28081
- const memoryIndexes = await this.getMemoryVectorIndexes();
28132
+ const memoryIndexes = await this.getMemoryVectorIndexes([this.messageIndexPrefix]);
28082
28133
  const idsToDelete = [...messageIdsNeedingDeletion];
28083
28134
  await Promise.all(memoryIndexes.map(async (indexName) => {
28084
28135
  for (let i = 0; i < idsToDelete.length; i += VECTOR_DELETE_BATCH_SIZE) {
@@ -28137,7 +28188,7 @@ Notes:
28137
28188
  const span = this.createMemorySpan("delete", observabilityContext, void 0, { messageCount: messageIds.length });
28138
28189
  try {
28139
28190
  await (await this.getMemoryStore()).deleteMessages(messageIds);
28140
- if (this.vector) this.deleteMessageVectors(messageIds);
28191
+ if (this.vector) this.trackVectorCleanup(this.deleteMessageVectors(messageIds));
28141
28192
  span?.end({
28142
28193
  output: { success: true },
28143
28194
  attributes: { messageCount: messageIds.length }
@@ -28153,12 +28204,14 @@ Notes:
28153
28204
  /**
28154
28205
  * Deletes vector embeddings for specific messages.
28155
28206
  * This is called internally by deleteMessages to clean up orphaned vectors.
28207
+ * Only the message indexes are touched, because observation vectors can hold
28208
+ * text of other messages of the thread.
28156
28209
  *
28157
28210
  * @param messageIds - The IDs of the messages whose vectors should be deleted
28158
28211
  */
28159
28212
  async deleteMessageVectors(messageIds) {
28160
28213
  try {
28161
- const memoryIndexes = await this.getMemoryVectorIndexes();
28214
+ const memoryIndexes = await this.getMemoryVectorIndexes([this.messageIndexPrefix]);
28162
28215
  await Promise.all(memoryIndexes.map(async (indexName) => {
28163
28216
  for (let i = 0; i < messageIds.length; i += VECTOR_DELETE_BATCH_SIZE) {
28164
28217
  const batch = messageIds.slice(i, i + VECTOR_DELETE_BATCH_SIZE);
@@ -28785,4 +28838,4 @@ Object.defineProperty(exports, "wrapInObservationGroup", {
28785
28838
  }
28786
28839
  });
28787
28840
 
28788
- //# sourceMappingURL=src-x5iu_K3X.cjs.map
28841
+ //# sourceMappingURL=src-DY9-_lul.cjs.map