@mastra/evals 1.10.1 → 1.10.2-alpha.1

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.
@@ -250,8 +250,10 @@ export declare const getReasoningFromRunOutput: (output?: ScorerRunOutputForAgen
250
250
  * @param options.toolCallId - Unique identifier for the tool call
251
251
  * @param options.toolName - Name of the tool being called
252
252
  * @param options.args - Arguments passed to the tool
253
- * @param options.result - Result returned by the tool
253
+ * @param options.result - Result returned by the tool (absent for a thrown call)
254
254
  * @param options.state - State of the invocation (default: 'result')
255
+ * @param options.errorText - Error text recorded when a tool threw (`state: 'output-error'`)
256
+ * @param options.isError - Set alongside `state: 'result'` when the executor reported a failure
255
257
  * @returns A tool invocation object
256
258
  *
257
259
  * @example
@@ -262,20 +264,33 @@ export declare const getReasoningFromRunOutput: (output?: ScorerRunOutputForAgen
262
264
  * args: { location: 'London' },
263
265
  * result: { temperature: 20, condition: 'sunny' },
264
266
  * });
267
+ *
268
+ * // A tool that threw
269
+ * const thrown = createToolInvocation({
270
+ * toolCallId: 'call-456',
271
+ * toolName: 'saveTool',
272
+ * args: { value: 'x' },
273
+ * state: 'output-error',
274
+ * errorText: 'Save failed',
275
+ * });
265
276
  * ```
266
277
  */
267
- export declare const createToolInvocation: ({ toolCallId, toolName, args, result, state, }: {
278
+ export declare const createToolInvocation: ({ toolCallId, toolName, args, result, state, errorText, isError, }: {
268
279
  toolCallId: string;
269
280
  toolName: string;
270
281
  args: Record<string, any>;
271
- result: Record<string, any>;
272
- state?: 'call' | 'partial-call' | 'result';
282
+ result?: Record<string, any>;
283
+ state?: 'call' | 'partial-call' | 'result' | 'output-error';
284
+ errorText?: string;
285
+ isError?: boolean;
273
286
  }) => {
274
287
  toolCallId: string;
275
288
  toolName: string;
276
289
  args: Record<string, any>;
277
- result: Record<string, any>;
278
- state: string;
290
+ result: Record<string, any> | undefined;
291
+ state: 'call' | 'partial-call' | 'result' | 'output-error';
292
+ errorText?: string;
293
+ isError?: boolean;
279
294
  };
280
295
  /**
281
296
  * Creates a MastraDBMessage object for testing purposes.
@@ -308,9 +323,28 @@ export declare const createToolInvocation: ({ toolCallId, toolName, args, result
308
323
  * state: 'result',
309
324
  * }],
310
325
  * });
326
+ *
327
+ * // With native V2 parts — the only form that can carry a thrown call
328
+ * const messageWithThrownTool = createTestMessage({
329
+ * content: 'That failed.',
330
+ * role: 'assistant',
331
+ * parts: [
332
+ * { type: 'text', text: 'That failed.' },
333
+ * {
334
+ * type: 'tool-invocation',
335
+ * toolInvocation: createToolInvocation({
336
+ * toolCallId: 'call-2',
337
+ * toolName: 'saveTool',
338
+ * args: { value: 'x' },
339
+ * state: 'output-error',
340
+ * errorText: 'Save failed',
341
+ * }),
342
+ * },
343
+ * ],
344
+ * });
311
345
  * ```
312
346
  */
313
- export declare function createTestMessage({ content, role, id, toolInvocations, }: {
347
+ export declare function createTestMessage({ content, role, id, toolInvocations, parts, }: {
314
348
  content: string;
315
349
  role: 'user' | 'assistant' | 'system';
316
350
  id?: string;
@@ -318,9 +352,15 @@ export declare function createTestMessage({ content, role, id, toolInvocations,
318
352
  toolCallId: string;
319
353
  toolName: string;
320
354
  args: Record<string, any>;
321
- result: Record<string, any>;
355
+ result?: Record<string, any>;
322
356
  state: any;
323
357
  }>;
358
+ /**
359
+ * Native V2 message parts. Replaces the default single text part when provided.
360
+ * Needed to express invocations the legacy array cannot carry, such as a thrown
361
+ * call (`state: 'output-error'` with `errorText`).
362
+ */
363
+ parts?: MastraDBMessage['content']['parts'];
324
364
  }): MastraDBMessage;
325
365
  /**
326
366
  * Creates a complete agent test run object for testing scorers.
@@ -410,11 +450,33 @@ export type ToolCallInfo = {
410
450
  /** Index of the invocation within the message's tool invocations */
411
451
  invocationIndex: number;
412
452
  };
453
+ /**
454
+ * Merges the two places a message can store tool invocations into one list.
455
+ *
456
+ * A native message may carry `content.parts` tool-invocation entries, the legacy
457
+ * `content.toolInvocations` array, or both. Neither form is a superset of the
458
+ * other: thrown calls are recorded in parts as `state: 'output-error'` and can be
459
+ * missing from the legacy array, while older persisted messages may only carry the
460
+ * legacy array. Reading one form exclusively therefore hides real calls.
461
+ *
462
+ * Parts win when the same `toolCallId` appears in both, since they hold the real
463
+ * terminal state. Legacy-only calls are retained before their next shared anchor so
464
+ * compatible call order survives instead of being appended.
465
+ *
466
+ * Mirrors `extractTrajectory` in `@mastra/core` (`packages/core/src/evals/types.ts`)
467
+ * so tool-use checks and trajectory scorers agree on what a run actually called.
468
+ * Keep the two in step.
469
+ *
470
+ * @param message - A single message from the scorer run output
471
+ * @returns The merged tool invocations for that message
472
+ */
473
+ export declare function mergeToolInvocations(message: MastraDBMessage | undefined): import("@mastra/core/agent/message-list").MastraToolInvocation[];
413
474
  /**
414
475
  * Extracts all tool calls from a scorer run output.
415
476
  *
416
- * Iterates through all messages and their tool invocations to collect
417
- * information about tools that were called (with state 'result' or 'call').
477
+ * Iterates through all messages and their tool invocations to collect information
478
+ * about tools that were called. A call counts regardless of outcome, so the states
479
+ * `'result'`, `'call'`, and `'output-error'` (a tool that threw) are all included.
418
480
  *
419
481
  * @param output - The scorer run output (array of MastraDBMessage)
420
482
  * @returns An object containing tool names and detailed tool call info
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/scorers/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EACtB,uBAAuB,EACvB,YAAY,EACZ,qBAAqB,EAErB,UAAU,EACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,MAAM,MAAM,yBAAyB,GACjC,sBAAsB,GACtB,MAAM,GACN;IACE,aAAa,CAAC,EAAE,OAAO,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,MAAM,CAAC,EAAE,MAA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;AAID;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,4CAA4C;IAC5C,iBAAiB,EAAE,MAAM,EAAE,EAAE,CAAC;CAC/B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE;IACP,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;CAC9B,GACL,yBAAyB,CAuC3B;AAID;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,UAAU,EAAE,MAAM,CAAC;IACnB,qEAAqE;IACrE,qBAAqB,EAAE,OAAO,CAAC;IAC/B,wCAAwC;IACxC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,6CAA6C;IAC7C,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IAC/B,+CAA+C;IAC/C,YAAY,EAAE,MAAM,CAAC;IACrB,8CAA8C;IAC9C,mBAAmB,EAAE,MAAM,EAAE,CAAC;CAC/B,CAAC;AAEF;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE;IACP,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACvB,GACL,yBAAyB,CAgE3B"}
@@ -351,8 +351,10 @@ const getReasoningFromRunOutput = (output) => {
351
351
  * @param options.toolCallId - Unique identifier for the tool call
352
352
  * @param options.toolName - Name of the tool being called
353
353
  * @param options.args - Arguments passed to the tool
354
- * @param options.result - Result returned by the tool
354
+ * @param options.result - Result returned by the tool (absent for a thrown call)
355
355
  * @param options.state - State of the invocation (default: 'result')
356
+ * @param options.errorText - Error text recorded when a tool threw (`state: 'output-error'`)
357
+ * @param options.isError - Set alongside `state: 'result'` when the executor reported a failure
356
358
  * @returns A tool invocation object
357
359
  *
358
360
  * @example
@@ -363,15 +365,26 @@ const getReasoningFromRunOutput = (output) => {
363
365
  * args: { location: 'London' },
364
366
  * result: { temperature: 20, condition: 'sunny' },
365
367
  * });
368
+ *
369
+ * // A tool that threw
370
+ * const thrown = createToolInvocation({
371
+ * toolCallId: 'call-456',
372
+ * toolName: 'saveTool',
373
+ * args: { value: 'x' },
374
+ * state: 'output-error',
375
+ * errorText: 'Save failed',
376
+ * });
366
377
  * ```
367
378
  */
368
- const createToolInvocation = ({ toolCallId, toolName, args, result, state = "result" }) => {
379
+ const createToolInvocation = ({ toolCallId, toolName, args, result, state = "result", errorText, isError }) => {
369
380
  return {
370
381
  toolCallId,
371
382
  toolName,
372
383
  args,
373
384
  result,
374
- state
385
+ state,
386
+ ...errorText !== void 0 && { errorText },
387
+ ...isError !== void 0 && { isError }
375
388
  };
376
389
  };
377
390
  /**
@@ -405,15 +418,34 @@ const createToolInvocation = ({ toolCallId, toolName, args, result, state = "res
405
418
  * state: 'result',
406
419
  * }],
407
420
  * });
421
+ *
422
+ * // With native V2 parts — the only form that can carry a thrown call
423
+ * const messageWithThrownTool = createTestMessage({
424
+ * content: 'That failed.',
425
+ * role: 'assistant',
426
+ * parts: [
427
+ * { type: 'text', text: 'That failed.' },
428
+ * {
429
+ * type: 'tool-invocation',
430
+ * toolInvocation: createToolInvocation({
431
+ * toolCallId: 'call-2',
432
+ * toolName: 'saveTool',
433
+ * args: { value: 'x' },
434
+ * state: 'output-error',
435
+ * errorText: 'Save failed',
436
+ * }),
437
+ * },
438
+ * ],
439
+ * });
408
440
  * ```
409
441
  */
410
- function createTestMessage({ content, role, id = "test-message", toolInvocations = [] }) {
442
+ function createTestMessage({ content, role, id = "test-message", toolInvocations = [], parts }) {
411
443
  return {
412
444
  id,
413
445
  role,
414
446
  content: {
415
447
  format: 2,
416
- parts: [{
448
+ parts: parts ?? [{
417
449
  type: "text",
418
450
  text: content
419
451
  }],
@@ -502,10 +534,56 @@ const createTrajectoryTestRun = ({ inputMessages = [], trajectory, rememberedMes
502
534
  };
503
535
  };
504
536
  /**
537
+ * Merges the two places a message can store tool invocations into one list.
538
+ *
539
+ * A native message may carry `content.parts` tool-invocation entries, the legacy
540
+ * `content.toolInvocations` array, or both. Neither form is a superset of the
541
+ * other: thrown calls are recorded in parts as `state: 'output-error'` and can be
542
+ * missing from the legacy array, while older persisted messages may only carry the
543
+ * legacy array. Reading one form exclusively therefore hides real calls.
544
+ *
545
+ * Parts win when the same `toolCallId` appears in both, since they hold the real
546
+ * terminal state. Legacy-only calls are retained before their next shared anchor so
547
+ * compatible call order survives instead of being appended.
548
+ *
549
+ * Mirrors `extractTrajectory` in `@mastra/core` (`packages/core/src/evals/types.ts`)
550
+ * so tool-use checks and trajectory scorers agree on what a run actually called.
551
+ * Keep the two in step.
552
+ *
553
+ * @param message - A single message from the scorer run output
554
+ * @returns The merged tool invocations for that message
555
+ */
556
+ function mergeToolInvocations(message) {
557
+ const legacy = message?.content?.toolInvocations;
558
+ const fromParts = message?.content?.parts?.filter((p) => p.type === "tool-invocation").map((p) => p.toolInvocation).filter(Boolean) ?? [];
559
+ const partCallIds = new Set(fromParts.map((invocation) => invocation.toolCallId).filter(Boolean));
560
+ const legacyInvocations = legacy ?? [];
561
+ const legacyPositions = new Map(legacyInvocations.map((invocation, index) => [invocation?.toolCallId, index]));
562
+ const toolInvocations = [];
563
+ let legacyIndex = 0;
564
+ for (const invocation of fromParts) {
565
+ const sharedIndex = invocation.toolCallId ? legacyPositions.get(invocation.toolCallId) : void 0;
566
+ if (sharedIndex !== void 0 && sharedIndex >= legacyIndex) {
567
+ for (; legacyIndex < sharedIndex; legacyIndex++) {
568
+ const previous = legacyInvocations[legacyIndex];
569
+ if (previous && !partCallIds.has(previous.toolCallId)) toolInvocations.push(previous);
570
+ }
571
+ legacyIndex++;
572
+ }
573
+ toolInvocations.push(invocation);
574
+ }
575
+ for (; legacyIndex < legacyInvocations.length; legacyIndex++) {
576
+ const invocation = legacyInvocations[legacyIndex];
577
+ if (invocation && !partCallIds.has(invocation.toolCallId)) toolInvocations.push(invocation);
578
+ }
579
+ return toolInvocations;
580
+ }
581
+ /**
505
582
  * Extracts all tool calls from a scorer run output.
506
583
  *
507
- * Iterates through all messages and their tool invocations to collect
508
- * information about tools that were called (with state 'result' or 'call').
584
+ * Iterates through all messages and their tool invocations to collect information
585
+ * about tools that were called. A call counts regardless of outcome, so the states
586
+ * `'result'`, `'call'`, and `'output-error'` (a tool that threw) are all included.
509
587
  *
510
588
  * @param output - The scorer run output (array of MastraDBMessage)
511
589
  * @returns An object containing tool names and detailed tool call info
@@ -527,13 +605,11 @@ function extractToolCalls(output) {
527
605
  const toolCallInfos = [];
528
606
  for (let messageIndex = 0; messageIndex < output.length; messageIndex++) {
529
607
  const message = output[messageIndex];
530
- const legacy = message?.content?.toolInvocations;
531
- const fromParts = legacy ? void 0 : message?.content?.parts?.filter((p) => p.type === "tool-invocation").map((p) => p.toolInvocation);
532
- const toolInvocations = legacy ?? fromParts;
533
- if (!toolInvocations?.length) continue;
608
+ const toolInvocations = mergeToolInvocations(message);
609
+ if (!toolInvocations.length) continue;
534
610
  for (let invocationIndex = 0; invocationIndex < toolInvocations.length; invocationIndex++) {
535
611
  const invocation = toolInvocations[invocationIndex];
536
- if (invocation && invocation.toolName && (invocation.state === "result" || invocation.state === "call")) {
612
+ if (invocation && invocation.toolName && (invocation.state === "result" || invocation.state === "call" || invocation.state === "output-error")) {
537
613
  toolCalls.push(invocation.toolName);
538
614
  toolCallInfos.push({
539
615
  toolName: invocation.toolName,
@@ -615,10 +691,8 @@ const extractAgentResponseMessages = (runOutput) => {
615
691
  function extractToolResults(output) {
616
692
  const results = [];
617
693
  for (const message of output) {
618
- const legacy = message?.content?.toolInvocations;
619
- const fromParts = legacy ? void 0 : message?.content?.parts?.filter((p) => p.type === "tool-invocation").map((p) => p.toolInvocation);
620
- const toolInvocations = legacy ?? fromParts;
621
- if (!toolInvocations?.length) continue;
694
+ const toolInvocations = mergeToolInvocations(message);
695
+ if (!toolInvocations.length) continue;
622
696
  for (const invocation of toolInvocations) if (invocation.state === "result" && invocation.result !== void 0) results.push({
623
697
  toolName: invocation.toolName,
624
698
  toolCallId: invocation.toolCallId || "",
@@ -1000,6 +1074,6 @@ function analyzeToolFailures(trajectory, options = {}) {
1000
1074
  };
1001
1075
  }
1002
1076
  //#endregion
1003
- export { analyzeToolFailures, checkTrajectoryBlacklist, checkTrajectoryEfficiency, compareTrajectories, createAgentTestRun, createTestMessage, createTestRun, createToolInvocation, createTrajectoryTestRun, extractAgentResponseMessages, extractInputMessages, extractToolCalls, extractToolResults, extractTrajectory, getAssistantMessageFromRunOutput, getCombinedSystemPrompt, getConversationHistoryFromRunInput, getReasoningFromRunOutput, getSystemMessagesFromRunInput, getTextContentFromMastraDBMessage, getUserMessageFromRunInput, isCloserTo, isScorerRunInputForAgent, isScorerRunOutputForAgent, roundToTwoDecimals };
1077
+ export { analyzeToolFailures, checkTrajectoryBlacklist, checkTrajectoryEfficiency, compareTrajectories, createAgentTestRun, createTestMessage, createTestRun, createToolInvocation, createTrajectoryTestRun, extractAgentResponseMessages, extractInputMessages, extractToolCalls, extractToolResults, extractTrajectory, getAssistantMessageFromRunOutput, getCombinedSystemPrompt, getConversationHistoryFromRunInput, getReasoningFromRunOutput, getSystemMessagesFromRunInput, getTextContentFromMastraDBMessage, getUserMessageFromRunInput, isCloserTo, isScorerRunInputForAgent, isScorerRunOutputForAgent, mergeToolInvocations, roundToTwoDecimals };
1004
1078
 
1005
1079
  //# sourceMappingURL=utils.js.map