@voltagent/core 1.1.34 → 1.1.35

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
@@ -3514,6 +3514,14 @@ declare class AgentTraceContext {
3514
3514
  cachedTokens?: number;
3515
3515
  reasoningTokens?: number;
3516
3516
  }): void;
3517
+ /**
3518
+ * Set finish reason on the root span
3519
+ */
3520
+ setFinishReason(finishReason: string | null | undefined): void;
3521
+ /**
3522
+ * Set stop condition metadata when maxSteps is reached
3523
+ */
3524
+ setStopConditionMet(stepCount: number, maxSteps: number): void;
3517
3525
  /**
3518
3526
  * End the root span with a status
3519
3527
  */
package/dist/index.d.ts CHANGED
@@ -3514,6 +3514,14 @@ declare class AgentTraceContext {
3514
3514
  cachedTokens?: number;
3515
3515
  reasoningTokens?: number;
3516
3516
  }): void;
3517
+ /**
3518
+ * Set finish reason on the root span
3519
+ */
3520
+ setFinishReason(finishReason: string | null | undefined): void;
3521
+ /**
3522
+ * Set stop condition metadata when maxSteps is reached
3523
+ */
3524
+ setStopConditionMet(stepCount: number, maxSteps: number): void;
3517
3525
  /**
3518
3526
  * End the root span with a status
3519
3527
  */
package/dist/index.js CHANGED
@@ -11251,6 +11251,24 @@ var AgentTraceContext = class {
11251
11251
  this.rootSpan.setAttribute("usage.reasoning_tokens", usage.reasoningTokens);
11252
11252
  }
11253
11253
  }
11254
+ /**
11255
+ * Set finish reason on the root span
11256
+ */
11257
+ setFinishReason(finishReason) {
11258
+ if (finishReason !== null && finishReason !== void 0) {
11259
+ this.rootSpan.setAttribute("ai.response.finish_reason", finishReason);
11260
+ }
11261
+ }
11262
+ /**
11263
+ * Set stop condition metadata when maxSteps is reached
11264
+ */
11265
+ setStopConditionMet(stepCount, maxSteps) {
11266
+ this.rootSpan.setAttributes({
11267
+ "voltagent.stopped_by_max_steps": true,
11268
+ "voltagent.step_count": stepCount,
11269
+ "voltagent.max_steps": maxSteps
11270
+ });
11271
+ }
11254
11272
  /**
11255
11273
  * End the root span with a status
11256
11274
  */
@@ -14553,6 +14571,10 @@ var Agent = class {
14553
14571
  );
14554
14572
  this.setTraceContextUsage(oc.traceContext, result.usage);
14555
14573
  oc.traceContext.setOutput(finalText);
14574
+ oc.traceContext.setFinishReason(result.finishReason);
14575
+ if (result.steps && result.steps.length >= maxSteps) {
14576
+ oc.traceContext.setStopConditionMet(result.steps.length, maxSteps);
14577
+ }
14556
14578
  oc.output = finalText;
14557
14579
  this.enqueueEvalScoring({
14558
14580
  oc,
@@ -14713,6 +14735,11 @@ var Agent = class {
14713
14735
  }
14714
14736
  const guardrailedResult = guardrailSet.output.length > 0 ? { ...finalResult, text: finalText } : finalResult;
14715
14737
  oc.traceContext.setOutput(finalText);
14738
+ oc.traceContext.setFinishReason(finalResult.finishReason);
14739
+ const steps = finalResult.steps;
14740
+ if (steps && steps.length >= maxSteps) {
14741
+ oc.traceContext.setStopConditionMet(steps.length, maxSteps);
14742
+ }
14716
14743
  oc.output = finalText;
14717
14744
  await this.getMergedHooks(options).onEnd?.({
14718
14745
  conversationId: oc.conversationId || "",