@sanity/ailf 0.1.20 → 0.1.21
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.
|
@@ -324,13 +324,25 @@ function calculateScores(resultsPath, weights) {
|
|
|
324
324
|
/**
|
|
325
325
|
* Extracts agent behavior summary from a test result's metadata.
|
|
326
326
|
* Returns null if the test was not run with the instrumented provider.
|
|
327
|
+
*
|
|
328
|
+
* Checks two locations because Promptfoo may flatten/merge the metadata
|
|
329
|
+
* object differently than how the provider originally set it:
|
|
330
|
+
* 1. metadata.agentBehaviorSummary (set directly by AgenticProvider)
|
|
331
|
+
* 2. metadata.agentBehavior.summary (nested in the full behavior log)
|
|
327
332
|
*/
|
|
328
333
|
function extractAgentBehavior(test) {
|
|
329
334
|
const { metadata } = test;
|
|
330
|
-
if (
|
|
331
|
-
return
|
|
335
|
+
if (metadata?.agentBehaviorSummary) {
|
|
336
|
+
return metadata.agentBehaviorSummary;
|
|
337
|
+
}
|
|
338
|
+
// Fallback: Promptfoo may drop the top-level agentBehaviorSummary
|
|
339
|
+
// field during serialization, but the data is nested inside the
|
|
340
|
+
// full agentBehavior log.
|
|
341
|
+
const behavior = metadata?.agentBehavior;
|
|
342
|
+
if (behavior?.summary) {
|
|
343
|
+
return behavior.summary;
|
|
332
344
|
}
|
|
333
|
-
return
|
|
345
|
+
return null;
|
|
334
346
|
}
|
|
335
347
|
/**
|
|
336
348
|
* Extracts grader (assertion) cost from the raw Promptfoo results file.
|