@voltagent/core 1.1.2 → 1.1.3

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
@@ -9094,8 +9094,8 @@ var Agent = class {
9094
9094
  // Preserve prototype chain
9095
9095
  result,
9096
9096
  // Copy all enumerable properties
9097
- { context: new Map(oc.context) }
9098
- // Add context
9097
+ { context: oc.context }
9098
+ // Expose the same context instance
9099
9099
  );
9100
9100
  return returnValue;
9101
9101
  } catch (error) {
@@ -9305,7 +9305,7 @@ var Agent = class {
9305
9305
  pipeTextStreamToResponse: result.pipeTextStreamToResponse.bind(result),
9306
9306
  toTextStreamResponse: result.toTextStreamResponse.bind(result),
9307
9307
  // Add our custom context
9308
- context: new Map(oc.context)
9308
+ context: oc.context
9309
9309
  };
9310
9310
  return resultWithContext;
9311
9311
  } catch (error) {
@@ -9440,7 +9440,7 @@ var Agent = class {
9440
9440
  );
9441
9441
  return {
9442
9442
  ...result,
9443
- context: new Map(oc.context)
9443
+ context: oc.context
9444
9444
  };
9445
9445
  } catch (error) {
9446
9446
  return this.handleError(error, oc, options, startTime);
@@ -9610,7 +9610,7 @@ var Agent = class {
9610
9610
  pipeTextStreamToResponse: /* @__PURE__ */ __name((response, init) => result.pipeTextStreamToResponse(response, init), "pipeTextStreamToResponse"),
9611
9611
  toTextStreamResponse: /* @__PURE__ */ __name((init) => result.toTextStreamResponse(init), "toTextStreamResponse"),
9612
9612
  // Add our custom context
9613
- context: new Map(oc.context)
9613
+ context: oc.context
9614
9614
  };
9615
9615
  return resultWithContext;
9616
9616
  } catch (error) {
@@ -9648,11 +9648,32 @@ var Agent = class {
9648
9648
  const operationId = crypto5.randomUUID();
9649
9649
  const startTimeDate = /* @__PURE__ */ new Date();
9650
9650
  const runtimeContext = toContextMap(options?.context);
9651
- const context5 = new Map([
9652
- ...this.context?.entries() || [],
9653
- ...runtimeContext?.entries() || [],
9654
- ...options?.parentOperationContext?.context?.entries() || []
9655
- ]);
9651
+ const parentContext = options?.parentOperationContext?.context;
9652
+ let context5;
9653
+ if (parentContext) {
9654
+ context5 = parentContext;
9655
+ if (runtimeContext) {
9656
+ for (const [k, v] of runtimeContext.entries()) {
9657
+ if (!context5.has(k)) context5.set(k, v);
9658
+ }
9659
+ }
9660
+ if (this.context) {
9661
+ for (const [k, v] of this.context.entries()) {
9662
+ if (!context5.has(k)) context5.set(k, v);
9663
+ }
9664
+ }
9665
+ } else if (runtimeContext) {
9666
+ context5 = runtimeContext;
9667
+ if (this.context) {
9668
+ for (const [k, v] of this.context.entries()) {
9669
+ if (!context5.has(k)) context5.set(k, v);
9670
+ }
9671
+ }
9672
+ } else if (this.context) {
9673
+ context5 = this.context;
9674
+ } else {
9675
+ context5 = /* @__PURE__ */ new Map();
9676
+ }
9656
9677
  const logger = this.getContextualLogger(options?.parentAgentId).child({
9657
9678
  operationId,
9658
9679
  userId: options?.userId,