@agent-inspect/eval 6.31.38 → 6.31.39
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.cjs +70 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +70 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1496,12 +1496,19 @@ function numericAttribute(node, keys) {
|
|
|
1496
1496
|
}
|
|
1497
1497
|
return void 0;
|
|
1498
1498
|
}
|
|
1499
|
-
function
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1499
|
+
function measuredTotalTokens(event) {
|
|
1500
|
+
const usage = event.tokenUsage;
|
|
1501
|
+
if (!usage) return void 0;
|
|
1502
|
+
if (typeof usage.total === "number" && Number.isFinite(usage.total)) return usage.total;
|
|
1503
|
+
const input = usage.input;
|
|
1504
|
+
const output = usage.output;
|
|
1505
|
+
if (typeof input === "number" && Number.isFinite(input) && typeof output === "number" && Number.isFinite(output)) {
|
|
1506
|
+
return input + output;
|
|
1507
|
+
}
|
|
1508
|
+
return void 0;
|
|
1509
|
+
}
|
|
1510
|
+
function llmEventsForTokenBudget(events) {
|
|
1511
|
+
return events.filter((event) => event.kind === "LLM");
|
|
1505
1512
|
}
|
|
1506
1513
|
function createRule(id, category, evaluate) {
|
|
1507
1514
|
return { id, category, severity: "error", evaluate };
|
|
@@ -1759,16 +1766,63 @@ var checks = {
|
|
|
1759
1766
|
},
|
|
1760
1767
|
maxTotalTokens(maxTotalTokens) {
|
|
1761
1768
|
return createRule("eval.maxTotalTokens", "llm", (context) => {
|
|
1762
|
-
const
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1769
|
+
const llms = llmEventsForTokenBudget(context.events);
|
|
1770
|
+
const findings = [];
|
|
1771
|
+
const missing = llms.filter((event) => measuredTotalTokens(event) === void 0);
|
|
1772
|
+
if (missing.length > 0) {
|
|
1773
|
+
const errored = missing.filter((event) => event.status === "error");
|
|
1774
|
+
const other = missing.filter((event) => event.status !== "error");
|
|
1775
|
+
const evidenceForPersisted = (events) => events.map((event) => ({
|
|
1776
|
+
runId: event.runId,
|
|
1777
|
+
eventId: event.eventId,
|
|
1778
|
+
kind: event.kind,
|
|
1779
|
+
name: event.name,
|
|
1780
|
+
path: "tokenUsage.total"
|
|
1781
|
+
}));
|
|
1782
|
+
if (errored.length > 0) {
|
|
1783
|
+
findings.push(
|
|
1784
|
+
fail2(
|
|
1785
|
+
"eval.maxTotalTokens",
|
|
1786
|
+
`Unverifiable total token budget: ${errored.length} of ${llms.length} LLM call(s) ended in error without measurable total usage.`,
|
|
1787
|
+
evidenceForPersisted(errored),
|
|
1788
|
+
"measurable total token usage on every LLM call",
|
|
1789
|
+
{
|
|
1790
|
+
reason: "unverifiable",
|
|
1791
|
+
callsWithoutUsage: errored.length,
|
|
1792
|
+
calls: llms.length
|
|
1793
|
+
}
|
|
1794
|
+
)
|
|
1795
|
+
);
|
|
1796
|
+
}
|
|
1797
|
+
if (other.length > 0) {
|
|
1798
|
+
findings.push(
|
|
1799
|
+
fail2(
|
|
1800
|
+
"eval.maxTotalTokens",
|
|
1801
|
+
`No measurable total token usage was read for ${other.length} of ${llms.length} LLM call(s), so the total token limit cannot be verified.`,
|
|
1802
|
+
evidenceForPersisted(other),
|
|
1803
|
+
"measurable total token usage on every LLM call",
|
|
1804
|
+
{
|
|
1805
|
+
reason: "unverifiable",
|
|
1806
|
+
callsWithoutUsage: other.length,
|
|
1807
|
+
calls: llms.length
|
|
1808
|
+
}
|
|
1809
|
+
)
|
|
1810
|
+
);
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
const total = llms.reduce((sum, event) => sum + (measuredTotalTokens(event) ?? 0), 0);
|
|
1814
|
+
if (total > maxTotalTokens) {
|
|
1815
|
+
findings.push(
|
|
1816
|
+
fail2(
|
|
1817
|
+
"eval.maxTotalTokens",
|
|
1818
|
+
`Total token usage exceeded ${maxTotalTokens}.`,
|
|
1819
|
+
evidenceForRun(context.run, "tokenUsage.total"),
|
|
1820
|
+
{ maxTotalTokens },
|
|
1821
|
+
total
|
|
1822
|
+
)
|
|
1823
|
+
);
|
|
1824
|
+
}
|
|
1825
|
+
return findings;
|
|
1772
1826
|
});
|
|
1773
1827
|
},
|
|
1774
1828
|
noFailedSteps() {
|