@voltagent/core 2.6.6 → 2.6.7

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.
package/dist/index.d.mts CHANGED
@@ -8404,6 +8404,11 @@ interface CommonRuntimeMemoryBehaviorOptions {
8404
8404
  contextLimit?: number;
8405
8405
  semanticMemory?: CommonSemanticMemoryOptions;
8406
8406
  conversationPersistence?: AgentConversationPersistenceOptions;
8407
+ /**
8408
+ * When true, memory is read-only for the current call.
8409
+ * Existing memory context can be loaded, but no writes are persisted.
8410
+ */
8411
+ readOnly?: boolean;
8407
8412
  }
8408
8413
  interface CommonRuntimeMemoryEnvelope {
8409
8414
  conversationId?: string;
@@ -8418,6 +8423,7 @@ interface CommonResolvedRuntimeMemoryOptions {
8418
8423
  contextLimit?: number;
8419
8424
  semanticMemory?: CommonSemanticMemoryOptions;
8420
8425
  conversationPersistence?: AgentConversationPersistenceOptions;
8426
+ readOnly?: boolean;
8421
8427
  }
8422
8428
  /**
8423
8429
  * Agent status information
@@ -9039,7 +9045,9 @@ declare class MemoryManager {
9039
9045
  * Ensures context is always loaded, optimizes non-critical operations in background
9040
9046
  * PRESERVED FROM ORIGINAL
9041
9047
  */
9042
- prepareConversationContext(context: OperationContext, input: string | UIMessage[], userId?: string, conversationIdParam?: string, contextLimit?: number): Promise<{
9048
+ prepareConversationContext(context: OperationContext, input: string | UIMessage[], userId?: string, conversationIdParam?: string, contextLimit?: number, options?: {
9049
+ persistInput?: boolean;
9050
+ }): Promise<{
9043
9051
  messages: UIMessage<{
9044
9052
  createdAt: Date;
9045
9053
  }>[];
@@ -9376,6 +9384,8 @@ declare class Agent {
9376
9384
  private resetOperationAttemptState;
9377
9385
  private getConversationBuffer;
9378
9386
  private getMemoryPersistQueue;
9387
+ private isReadOnlyMemoryForContext;
9388
+ private shouldPersistMemoryForContext;
9379
9389
  private ensureStreamingResponseMessageId;
9380
9390
  private getOrCreateStepResponseMessageId;
9381
9391
  private getStepResponseMessageFingerprints;
package/dist/index.d.ts CHANGED
@@ -8404,6 +8404,11 @@ interface CommonRuntimeMemoryBehaviorOptions {
8404
8404
  contextLimit?: number;
8405
8405
  semanticMemory?: CommonSemanticMemoryOptions;
8406
8406
  conversationPersistence?: AgentConversationPersistenceOptions;
8407
+ /**
8408
+ * When true, memory is read-only for the current call.
8409
+ * Existing memory context can be loaded, but no writes are persisted.
8410
+ */
8411
+ readOnly?: boolean;
8407
8412
  }
8408
8413
  interface CommonRuntimeMemoryEnvelope {
8409
8414
  conversationId?: string;
@@ -8418,6 +8423,7 @@ interface CommonResolvedRuntimeMemoryOptions {
8418
8423
  contextLimit?: number;
8419
8424
  semanticMemory?: CommonSemanticMemoryOptions;
8420
8425
  conversationPersistence?: AgentConversationPersistenceOptions;
8426
+ readOnly?: boolean;
8421
8427
  }
8422
8428
  /**
8423
8429
  * Agent status information
@@ -9039,7 +9045,9 @@ declare class MemoryManager {
9039
9045
  * Ensures context is always loaded, optimizes non-critical operations in background
9040
9046
  * PRESERVED FROM ORIGINAL
9041
9047
  */
9042
- prepareConversationContext(context: OperationContext, input: string | UIMessage[], userId?: string, conversationIdParam?: string, contextLimit?: number): Promise<{
9048
+ prepareConversationContext(context: OperationContext, input: string | UIMessage[], userId?: string, conversationIdParam?: string, contextLimit?: number, options?: {
9049
+ persistInput?: boolean;
9050
+ }): Promise<{
9043
9051
  messages: UIMessage<{
9044
9052
  createdAt: Date;
9045
9053
  }>[];
@@ -9376,6 +9384,8 @@ declare class Agent {
9376
9384
  private resetOperationAttemptState;
9377
9385
  private getConversationBuffer;
9378
9386
  private getMemoryPersistQueue;
9387
+ private isReadOnlyMemoryForContext;
9388
+ private shouldPersistMemoryForContext;
9379
9389
  private ensureStreamingResponseMessageId;
9380
9390
  private getOrCreateStepResponseMessageId;
9381
9391
  private getStepResponseMessageFingerprints;
package/dist/index.js CHANGED
@@ -13068,7 +13068,7 @@ var MemoryManager = class {
13068
13068
  * Ensures context is always loaded, optimizes non-critical operations in background
13069
13069
  * PRESERVED FROM ORIGINAL
13070
13070
  */
13071
- async prepareConversationContext(context8, input, userId, conversationIdParam, contextLimit = 10) {
13071
+ async prepareConversationContext(context8, input, userId, conversationIdParam, contextLimit = 10, options) {
13072
13072
  const conversationId = conversationIdParam || randomUUID();
13073
13073
  if (contextLimit === 0) {
13074
13074
  return { messages: [], conversationId };
@@ -13098,7 +13098,9 @@ var MemoryManager = class {
13098
13098
  error
13099
13099
  });
13100
13100
  }
13101
- this.handleSequentialBackgroundOperations(context8, input, userId, conversationId);
13101
+ if (options?.persistInput !== false) {
13102
+ this.handleSequentialBackgroundOperations(context8, input, userId, conversationId);
13103
+ }
13102
13104
  return { messages, conversationId };
13103
13105
  }
13104
13106
  /**
@@ -21481,24 +21483,18 @@ var truncateByBytes = /* @__PURE__ */ __name((value, maxBytes) => {
21481
21483
  const truncated = buf.subarray(0, targetBytes).toString("utf-8");
21482
21484
  return `${truncated}${TRUNCATION_SUFFIX}`;
21483
21485
  }, "truncateByBytes");
21484
- var formatStreamOutput = /* @__PURE__ */ __name((label, info) => {
21485
- const lines = [];
21486
+ var formatStreamSummary = /* @__PURE__ */ __name((label, info) => {
21486
21487
  if (info.evicted && info.path) {
21487
- const note = info.truncated ? " (truncated)" : "";
21488
- lines.push(`${label}: saved to ${info.path} (${info.bytes} bytes${note})`);
21489
- if (info.error) {
21490
- lines.push(`${label} eviction error: ${info.error}`);
21491
- }
21492
- return lines;
21488
+ const note = info.truncated ? ", truncated" : "";
21489
+ const errorNote = info.error ? `, eviction error: ${info.error}` : "";
21490
+ return `${label}: saved to ${info.path} (${info.bytes} bytes${note}${errorNote})`;
21493
21491
  }
21494
21492
  if (info.content) {
21495
- lines.push(`${label}:`);
21496
- lines.push(info.content);
21497
- return lines;
21493
+ const note = info.truncated ? ", truncated" : "";
21494
+ return `${label}: captured inline (${info.bytes} bytes${note})`;
21498
21495
  }
21499
- lines.push(`${label}: (empty)`);
21500
- return lines;
21501
- }, "formatStreamOutput");
21496
+ return `${label}: (empty)`;
21497
+ }, "formatStreamSummary");
21502
21498
  var createWorkspaceSandboxToolkit = /* @__PURE__ */ __name((context8, options = {}) => {
21503
21499
  const pathContext = resolvePathContext(context8);
21504
21500
  const systemPrompt = options.systemPrompt === void 0 ? buildSystemPrompt(pathContext) : options.systemPrompt;
@@ -21631,8 +21627,8 @@ var createWorkspaceSandboxToolkit = /* @__PURE__ */ __name((context8, options =
21631
21627
  const stderrInfo = await evictStream("stderr", result.stderr, result.stderrTruncated);
21632
21628
  const lines = [];
21633
21629
  lines.push(...formatSandboxHeader(result));
21634
- lines.push(...formatStreamOutput("STDOUT", stdoutInfo));
21635
- lines.push(...formatStreamOutput("STDERR", stderrInfo));
21630
+ lines.push(formatStreamSummary("STDOUT", stdoutInfo));
21631
+ lines.push(formatStreamSummary("STDERR", stderrInfo));
21636
21632
  const summary = lines.join("\n");
21637
21633
  const streamErrors = [stdoutInfo.error, stderrInfo.error].filter(
21638
21634
  (value) => Boolean(value)
@@ -30041,6 +30037,14 @@ var firstNonBlank = /* @__PURE__ */ __name((...values) => {
30041
30037
  }
30042
30038
  return void 0;
30043
30039
  }, "firstNonBlank");
30040
+ var firstDefined = /* @__PURE__ */ __name((...values) => {
30041
+ for (const value of values) {
30042
+ if (value !== null && value !== void 0) {
30043
+ return value;
30044
+ }
30045
+ }
30046
+ return void 0;
30047
+ }, "firstDefined");
30044
30048
  var isAssistantContentPart = /* @__PURE__ */ __name((value) => {
30045
30049
  if (!isRecord4(value)) {
30046
30050
  return false;
@@ -30445,6 +30449,7 @@ var Agent = class {
30445
30449
  const feedbackOptions = this.resolveFeedbackOptions(options);
30446
30450
  const feedbackClient = feedbackOptions ? this.getFeedbackClient() : void 0;
30447
30451
  const shouldDeferPersist = Boolean(feedbackOptions && feedbackClient);
30452
+ const shouldPersistMemory = this.shouldPersistMemoryForContext(oc);
30448
30453
  let feedbackMetadata = null;
30449
30454
  const rootSpan = oc.traceContext.getRootSpan();
30450
30455
  return await oc.traceContext.withSpan(rootSpan, async () => {
@@ -30640,7 +30645,7 @@ var Agent = class {
30640
30645
  }
30641
30646
  );
30642
30647
  void this.recordStepResults(result.steps, oc);
30643
- if (!shouldDeferPersist) {
30648
+ if (!shouldDeferPersist && shouldPersistMemory) {
30644
30649
  await persistQueue.flush(buffer, oc);
30645
30650
  }
30646
30651
  const finalText = await runOutputGuardrails({
@@ -30722,7 +30727,7 @@ var Agent = class {
30722
30727
  }
30723
30728
  }
30724
30729
  }
30725
- if (shouldDeferPersist) {
30730
+ if (shouldDeferPersist && shouldPersistMemory) {
30726
30731
  await persistQueue.flush(buffer, oc);
30727
30732
  }
30728
30733
  const feedbackValue = (() => {
@@ -30848,6 +30853,7 @@ var Agent = class {
30848
30853
  const feedbackOptions = this.resolveFeedbackOptions(options);
30849
30854
  const feedbackClient = feedbackOptions ? this.getFeedbackClient() : void 0;
30850
30855
  const shouldDeferPersist = Boolean(feedbackOptions && feedbackClient);
30856
+ const shouldPersistMemory = this.shouldPersistMemoryForContext(oc);
30851
30857
  const feedbackDeferred = feedbackOptions ? createDeferred() : null;
30852
30858
  let feedbackMetadataValue = null;
30853
30859
  let feedbackValue = null;
@@ -30887,7 +30893,7 @@ var Agent = class {
30887
30893
  { requirePending: true }
30888
30894
  );
30889
30895
  }
30890
- if (shouldDeferPersist) {
30896
+ if (shouldDeferPersist && shouldPersistMemory) {
30891
30897
  void persistQueue.flush(buffer, oc).catch((error) => {
30892
30898
  oc.logger?.debug?.("Failed to persist feedback metadata", { error });
30893
30899
  });
@@ -31162,7 +31168,7 @@ var Agent = class {
31162
31168
  usage: providerUsage,
31163
31169
  finishReason: finalResult.finishReason
31164
31170
  });
31165
- if (!shouldDeferPersist) {
31171
+ if (!shouldDeferPersist && shouldPersistMemory) {
31166
31172
  await persistQueue.flush(buffer, oc);
31167
31173
  }
31168
31174
  this.setTraceContextUsage(oc.traceContext, usageForFinish);
@@ -31276,7 +31282,7 @@ var Agent = class {
31276
31282
  }
31277
31283
  if (feedbackResolved && feedbackMetadataValue) {
31278
31284
  scheduleFeedbackPersist(feedbackMetadataValue);
31279
- } else if (shouldDeferPersist) {
31285
+ } else if (shouldDeferPersist && shouldPersistMemory) {
31280
31286
  void persistQueue.flush(buffer, oc).catch((error) => {
31281
31287
  oc.logger?.debug?.("Failed to persist deferred messages", { error });
31282
31288
  });
@@ -31749,7 +31755,7 @@ var Agent = class {
31749
31755
  warnings: result.warnings ?? null
31750
31756
  }
31751
31757
  });
31752
- if (oc.userId && oc.conversationId) {
31758
+ if (this.shouldPersistMemoryForContext(oc) && oc.userId && oc.conversationId) {
31753
31759
  const message = {
31754
31760
  id: randomUUID(),
31755
31761
  role: "assistant",
@@ -32095,7 +32101,7 @@ var Agent = class {
32095
32101
  });
32096
32102
  resolveGuardrailObject?.(finalObject);
32097
32103
  }
32098
- if (oc.userId && oc.conversationId) {
32104
+ if (this.shouldPersistMemoryForContext(oc) && oc.userId && oc.conversationId) {
32099
32105
  const message = {
32100
32106
  id: randomUUID(),
32101
32107
  role: "assistant",
@@ -32388,7 +32394,12 @@ Metadata: ${(0, import_utils33.safeStringify)(metadata)}`;
32388
32394
  ),
32389
32395
  contextLimit: contextResolvedMemory?.contextLimit ?? memoryOptions?.contextLimit ?? options?.contextLimit ?? parentResolvedMemory?.contextLimit,
32390
32396
  semanticMemory: contextResolvedMemory?.semanticMemory ?? memoryOptions?.semanticMemory ?? options?.semanticMemory ?? parentResolvedMemory?.semanticMemory,
32391
- conversationPersistence: contextResolvedMemory?.conversationPersistence ?? memoryOptions?.conversationPersistence ?? options?.conversationPersistence ?? parentResolvedMemory?.conversationPersistence
32397
+ conversationPersistence: contextResolvedMemory?.conversationPersistence ?? memoryOptions?.conversationPersistence ?? options?.conversationPersistence ?? parentResolvedMemory?.conversationPersistence,
32398
+ readOnly: firstDefined(
32399
+ contextResolvedMemory?.readOnly,
32400
+ memoryOptions?.readOnly,
32401
+ parentResolvedMemory?.readOnly
32402
+ )
32392
32403
  };
32393
32404
  }
32394
32405
  getConversationPersistenceOptionsForContext(oc) {
@@ -32546,6 +32557,12 @@ Metadata: ${(0, import_utils33.safeStringify)(metadata)}`;
32546
32557
  }
32547
32558
  return queue;
32548
32559
  }
32560
+ isReadOnlyMemoryForContext(oc) {
32561
+ return oc.resolvedMemory?.readOnly === true;
32562
+ }
32563
+ shouldPersistMemoryForContext(oc) {
32564
+ return !this.isReadOnlyMemoryForContext(oc);
32565
+ }
32549
32566
  async ensureStreamingResponseMessageId(oc, buffer) {
32550
32567
  const messageId = this.getOrCreateStepResponseMessageId(oc);
32551
32568
  const placeholder = {
@@ -32598,6 +32615,9 @@ Metadata: ${(0, import_utils33.safeStringify)(metadata)}`;
32598
32615
  return normalized.length > 0 ? normalized : void 0;
32599
32616
  }
32600
32617
  async flushPendingMessagesOnError(oc) {
32618
+ if (!this.shouldPersistMemoryForContext(oc)) {
32619
+ return;
32620
+ }
32601
32621
  const buffer = this.getConversationBuffer(oc);
32602
32622
  const queue = this.getMemoryPersistQueue(oc);
32603
32623
  if (!buffer || !queue) {
@@ -33006,6 +33026,7 @@ Metadata: ${(0, import_utils33.safeStringify)(metadata)}`;
33006
33026
  const messages = [];
33007
33027
  const resolvedMemory = this.resolveMemoryRuntimeOptions(options, oc);
33008
33028
  const canIUseMemory = Boolean(resolvedMemory.userId);
33029
+ const shouldPersistMemory = resolvedMemory.readOnly !== true;
33009
33030
  const memoryContextMessages = [];
33010
33031
  if (canIUseMemory) {
33011
33032
  const useSemanticSearch = resolvedMemory.semanticMemory?.enabled ?? this.hasSemanticSearchSupport();
@@ -33061,7 +33082,8 @@ Metadata: ${(0, import_utils33.safeStringify)(metadata)}`;
33061
33082
  inputForMemory,
33062
33083
  oc.userId,
33063
33084
  oc.conversationId,
33064
- resolvedMemory.contextLimit
33085
+ resolvedMemory.contextLimit,
33086
+ { persistInput: shouldPersistMemory }
33065
33087
  );
33066
33088
  oc.conversationId = result.conversationId;
33067
33089
  if (oc.resolvedMemory) {
@@ -33084,7 +33106,7 @@ Metadata: ${(0, import_utils33.safeStringify)(metadata)}`;
33084
33106
  }
33085
33107
  }
33086
33108
  memoryContextMessages.push(...memoryResult);
33087
- if (isSemanticSearch && oc.userId && oc.conversationId) {
33109
+ if (isSemanticSearch && shouldPersistMemory && oc.userId && oc.conversationId) {
33088
33110
  try {
33089
33111
  const inputForMemory = typeof resolvedInput === "string" ? resolvedInput : Array.isArray(resolvedInput) && resolvedInput[0]?.parts ? resolvedInput : convertModelMessagesToUIMessages(resolvedInput);
33090
33112
  this.memoryManager.queueSaveInput(oc, inputForMemory, oc.userId, oc.conversationId);
@@ -34770,7 +34792,8 @@ ${retrieverContext}`;
34770
34792
  */
34771
34793
  createStepHandler(oc, options) {
34772
34794
  const buffer = this.getConversationBuffer(oc);
34773
- const persistQueue = this.getMemoryPersistQueue(oc);
34795
+ const shouldPersistMemory = this.shouldPersistMemoryForContext(oc);
34796
+ const persistQueue = shouldPersistMemory ? this.getMemoryPersistQueue(oc) : null;
34774
34797
  const conversationPersistence = this.getConversationPersistenceOptionsForContext(oc);
34775
34798
  return async (event) => {
34776
34799
  const { shouldFlushForToolCompletion, bailedResult } = this.processStepContent(oc, event);
@@ -34788,7 +34811,7 @@ ${retrieverContext}`;
34788
34811
  awaitPersistence: shouldFlushStepPersistence
34789
34812
  });
34790
34813
  }
34791
- if (conversationPersistence.mode === "step" && (hasResponseMessages || shouldFlushStepPersistence)) {
34814
+ if (shouldPersistMemory && persistQueue && conversationPersistence.mode === "step" && (hasResponseMessages || shouldFlushStepPersistence)) {
34792
34815
  try {
34793
34816
  if (shouldFlushStepPersistence) {
34794
34817
  await persistQueue.flush(buffer, oc);
@@ -35025,7 +35048,7 @@ ${retrieverContext}`;
35025
35048
  }
35026
35049
  recordTimestamp = (/* @__PURE__ */ new Date()).toISOString();
35027
35050
  });
35028
- if (stepRecords.length > 0 && oc.userId && oc.conversationId) {
35051
+ if (this.shouldPersistMemoryForContext(oc) && stepRecords.length > 0 && oc.userId && oc.conversationId) {
35029
35052
  const persistStepsPromise = this.memoryManager.saveConversationSteps(oc, stepRecords, oc.userId, oc.conversationId).catch((error) => {
35030
35053
  oc.logger.debug("Failed to persist conversation steps", {
35031
35054
  error,
@@ -35730,7 +35753,8 @@ ${retrieverContext}`;
35730
35753
  const memoryBehaviorOverrides = resolvedMemory ? {
35731
35754
  ...resolvedMemory.contextLimit !== void 0 ? { contextLimit: resolvedMemory.contextLimit } : {},
35732
35755
  ...resolvedMemory.semanticMemory !== void 0 ? { semanticMemory: resolvedMemory.semanticMemory } : {},
35733
- ...resolvedMemory.conversationPersistence !== void 0 ? { conversationPersistence: resolvedMemory.conversationPersistence } : {}
35756
+ ...resolvedMemory.conversationPersistence !== void 0 ? { conversationPersistence: resolvedMemory.conversationPersistence } : {},
35757
+ ...resolvedMemory.readOnly !== void 0 ? { readOnly: resolvedMemory.readOnly } : {}
35734
35758
  } : void 0;
35735
35759
  const memory = resolvedMemory || options2?.conversationId || options2?.userId ? {
35736
35760
  conversationId: resolvedMemory?.conversationId ?? options2?.conversationId,
@@ -35780,6 +35804,7 @@ ${retrieverContext}`;
35780
35804
  return [];
35781
35805
  }
35782
35806
  const resolvedMemory = this.resolveMemoryRuntimeOptions(options, operationContext);
35807
+ const isReadOnly = resolvedMemory.readOnly === true;
35783
35808
  const memoryManager = this.memoryManager;
35784
35809
  const memory = memoryManager.getMemory();
35785
35810
  if (!memory) {
@@ -35800,60 +35825,62 @@ ${retrieverContext}`;
35800
35825
  }, "execute")
35801
35826
  })
35802
35827
  );
35803
- const schema = memory.getWorkingMemorySchema();
35804
- const template = memory.getWorkingMemoryTemplate();
35805
- const baseParams = schema ? { content: schema } : { content: import_zod7.z.string().describe("The content to store in working memory") };
35806
- const modeParam = {
35807
- mode: import_zod7.z.enum(["replace", "append"]).default("append").describe(
35808
- "How to update: 'append' (default - safely merge with existing) or 'replace' (complete overwrite - DELETES other fields!)"
35809
- )
35810
- };
35811
- tools.push(
35812
- createTool({
35813
- name: "update_working_memory",
35814
- description: template ? `Update working memory. Default mode is 'append' which safely merges new data. Only use 'replace' if you want to COMPLETELY OVERWRITE all data. Current data is in <current_context>. Template: ${template}` : `Update working memory with important context. Default mode is 'append' which safely merges new data. Only use 'replace' if you want to COMPLETELY OVERWRITE all data. Current data is in <current_context>.`,
35815
- parameters: import_zod7.z.object({ ...baseParams, ...modeParam }),
35816
- execute: /* @__PURE__ */ __name(async ({ content, mode }, oc) => {
35817
- await memory.updateWorkingMemory({
35818
- conversationId: resolvedMemory.conversationId,
35819
- userId: resolvedMemory.userId,
35820
- content,
35821
- options: {
35822
- mode
35828
+ if (!isReadOnly) {
35829
+ const schema = memory.getWorkingMemorySchema();
35830
+ const template = memory.getWorkingMemoryTemplate();
35831
+ const baseParams = schema ? { content: schema } : { content: import_zod7.z.string().describe("The content to store in working memory") };
35832
+ const modeParam = {
35833
+ mode: import_zod7.z.enum(["replace", "append"]).default("append").describe(
35834
+ "How to update: 'append' (default - safely merge with existing) or 'replace' (complete overwrite - DELETES other fields!)"
35835
+ )
35836
+ };
35837
+ tools.push(
35838
+ createTool({
35839
+ name: "update_working_memory",
35840
+ description: template ? `Update working memory. Default mode is 'append' which safely merges new data. Only use 'replace' if you want to COMPLETELY OVERWRITE all data. Current data is in <current_context>. Template: ${template}` : `Update working memory with important context. Default mode is 'append' which safely merges new data. Only use 'replace' if you want to COMPLETELY OVERWRITE all data. Current data is in <current_context>.`,
35841
+ parameters: import_zod7.z.object({ ...baseParams, ...modeParam }),
35842
+ execute: /* @__PURE__ */ __name(async ({ content, mode }, oc) => {
35843
+ await memory.updateWorkingMemory({
35844
+ conversationId: resolvedMemory.conversationId,
35845
+ userId: resolvedMemory.userId,
35846
+ content,
35847
+ options: {
35848
+ mode
35849
+ }
35850
+ });
35851
+ if (oc?.traceContext) {
35852
+ const finalContent = await memory.getWorkingMemory({
35853
+ conversationId: resolvedMemory.conversationId,
35854
+ userId: resolvedMemory.userId
35855
+ });
35856
+ const rootSpan = oc.traceContext.getRootSpan();
35857
+ rootSpan.setAttribute("agent.workingMemory.finalContent", finalContent || "");
35858
+ rootSpan.setAttribute("agent.workingMemory.lastUpdateTime", (/* @__PURE__ */ new Date()).toISOString());
35823
35859
  }
35824
- });
35825
- if (oc?.traceContext) {
35826
- const finalContent = await memory.getWorkingMemory({
35860
+ return `Working memory ${mode === "replace" ? "replaced" : "updated (appended)"} successfully.`;
35861
+ }, "execute")
35862
+ })
35863
+ );
35864
+ tools.push(
35865
+ createTool({
35866
+ name: "clear_working_memory",
35867
+ description: "Clear the working memory content",
35868
+ parameters: import_zod7.z.object({}),
35869
+ execute: /* @__PURE__ */ __name(async (_, oc) => {
35870
+ await memory.clearWorkingMemory({
35827
35871
  conversationId: resolvedMemory.conversationId,
35828
35872
  userId: resolvedMemory.userId
35829
35873
  });
35830
- const rootSpan = oc.traceContext.getRootSpan();
35831
- rootSpan.setAttribute("agent.workingMemory.finalContent", finalContent || "");
35832
- rootSpan.setAttribute("agent.workingMemory.lastUpdateTime", (/* @__PURE__ */ new Date()).toISOString());
35833
- }
35834
- return `Working memory ${mode === "replace" ? "replaced" : "updated (appended)"} successfully.`;
35835
- }, "execute")
35836
- })
35837
- );
35838
- tools.push(
35839
- createTool({
35840
- name: "clear_working_memory",
35841
- description: "Clear the working memory content",
35842
- parameters: import_zod7.z.object({}),
35843
- execute: /* @__PURE__ */ __name(async (_, oc) => {
35844
- await memory.clearWorkingMemory({
35845
- conversationId: resolvedMemory.conversationId,
35846
- userId: resolvedMemory.userId
35847
- });
35848
- if (oc?.traceContext) {
35849
- const rootSpan = oc.traceContext.getRootSpan();
35850
- rootSpan.setAttribute("agent.workingMemory.finalContent", "");
35851
- rootSpan.setAttribute("agent.workingMemory.lastUpdateTime", (/* @__PURE__ */ new Date()).toISOString());
35852
- }
35853
- return "Working memory cleared.";
35854
- }, "execute")
35855
- })
35856
- );
35874
+ if (oc?.traceContext) {
35875
+ const rootSpan = oc.traceContext.getRootSpan();
35876
+ rootSpan.setAttribute("agent.workingMemory.finalContent", "");
35877
+ rootSpan.setAttribute("agent.workingMemory.lastUpdateTime", (/* @__PURE__ */ new Date()).toISOString());
35878
+ }
35879
+ return "Working memory cleared.";
35880
+ }, "execute")
35881
+ })
35882
+ );
35883
+ }
35857
35884
  return tools;
35858
35885
  }
35859
35886
  };