ai 4.3.18 → 4.3.19

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # ai
2
2
 
3
+ ## 4.3.19
4
+
5
+ ### Patch Changes
6
+
7
+ - 849af1c: feat(ai): Record tool call errors on tool call spans recorded in `generateText` and `streamText`.
8
+
3
9
  ## 4.3.18
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -572,19 +572,7 @@ function recordSpan({
572
572
  return result;
573
573
  } catch (error) {
574
574
  try {
575
- if (error instanceof Error) {
576
- span.recordException({
577
- name: error.name,
578
- message: error.message,
579
- stack: error.stack
580
- });
581
- span.setStatus({
582
- code: import_api2.SpanStatusCode.ERROR,
583
- message: error.message
584
- });
585
- } else {
586
- span.setStatus({ code: import_api2.SpanStatusCode.ERROR });
587
- }
575
+ recordErrorOnSpan(span, error);
588
576
  } finally {
589
577
  span.end();
590
578
  }
@@ -592,6 +580,21 @@ function recordSpan({
592
580
  }
593
581
  });
594
582
  }
583
+ function recordErrorOnSpan(span, error) {
584
+ if (error instanceof Error) {
585
+ span.recordException({
586
+ name: error.name,
587
+ message: error.message,
588
+ stack: error.stack
589
+ });
590
+ span.setStatus({
591
+ code: import_api2.SpanStatusCode.ERROR,
592
+ message: error.message
593
+ });
594
+ } else {
595
+ span.setStatus({ code: import_api2.SpanStatusCode.ERROR });
596
+ }
597
+ }
595
598
 
596
599
  // core/telemetry/select-telemetry-attributes.ts
597
600
  function selectTelemetryAttributes({
@@ -4649,6 +4652,7 @@ async function executeTools({
4649
4652
  }
4650
4653
  return result2;
4651
4654
  } catch (error) {
4655
+ recordErrorOnSpan(span, error);
4652
4656
  throw new ToolExecutionError({
4653
4657
  toolCallId,
4654
4658
  toolName,
@@ -5160,6 +5164,7 @@ function runToolsTransformation({
5160
5164
  }
5161
5165
  },
5162
5166
  (error) => {
5167
+ recordErrorOnSpan(span, error);
5163
5168
  toolResultsStreamController.enqueue({
5164
5169
  type: "error",
5165
5170
  error: new ToolExecutionError({