@voltagent/core 1.1.31 → 1.1.32

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.js CHANGED
@@ -14280,6 +14280,20 @@ function toContextMap(context8) {
14280
14280
  return context8 instanceof Map ? context8 : new Map(Object.entries(context8));
14281
14281
  }
14282
14282
  __name(toContextMap, "toContextMap");
14283
+ function stripExcessiveFieldsInUIMessages(uiMessages) {
14284
+ function isTextUIPart(p) {
14285
+ return typeof p === "object" && p !== null && p.type === "text";
14286
+ }
14287
+ __name(isTextUIPart, "isTextUIPart");
14288
+ return uiMessages.map((msg) => {
14289
+ if (!Array.isArray(msg.parts)) return msg;
14290
+ const parts = msg.parts?.map(
14291
+ (part) => isTextUIPart(part) ? { type: "text", text: part.text } : part
14292
+ );
14293
+ return { ...msg, parts };
14294
+ });
14295
+ }
14296
+ __name(stripExcessiveFieldsInUIMessages, "stripExcessiveFieldsInUIMessages");
14283
14297
  function cloneGenerateTextResultWithContext(result, overrides) {
14284
14298
  const prototype = Object.getPrototypeOf(result);
14285
14299
  const clone = Object.create(prototype);
@@ -15333,7 +15347,7 @@ var Agent = class {
15333
15347
  const buffer = this.getConversationBuffer(oc);
15334
15348
  const uiMessages = await this.prepareMessages(input, oc, options, buffer);
15335
15349
  const hooks = this.getMergedHooks(options);
15336
- let messages = (0, import_ai4.convertToModelMessages)(uiMessages);
15350
+ let messages = (0, import_ai4.convertToModelMessages)(stripExcessiveFieldsInUIMessages(uiMessages));
15337
15351
  if (hooks.onPrepareModelMessages) {
15338
15352
  const result = await hooks.onPrepareModelMessages({
15339
15353
  modelMessages: messages,
@@ -15968,7 +15982,7 @@ ${toolkit.instructions}`;
15968
15982
  }
15969
15983
  });
15970
15984
  try {
15971
- const retrieverInput = typeof input === "string" ? input : Array.isArray(input) && input[0]?.content !== void 0 ? input : (0, import_ai4.convertToModelMessages)(input);
15985
+ const retrieverInput = typeof input === "string" ? input : Array.isArray(input) && input[0]?.content !== void 0 ? input : (0, import_ai4.convertToModelMessages)(stripExcessiveFieldsInUIMessages(input));
15972
15986
  const retrievedContent = await oc.traceContext.withSpan(retrieverSpan, async () => {
15973
15987
  if (!this.retriever) return null;
15974
15988
  return await this.retriever.retrieve(retrieverInput, {