@agent-inspect/eval 6.31.40 → 6.31.42

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.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { TraceReadResult } from 'agent-inspect/readers';
1
+ import { TraceReadResult, TraceReadWarning } from 'agent-inspect/readers';
2
2
 
3
3
  type CircuitRuleId = "circuit.same-tool-repetition" | "circuit.same-args-repetition" | "circuit.max-loop-iterations" | "circuit.max-retries" | "circuit.tool-timeout" | "circuit.runaway-llm-loop" | "circuit.excessive-branch-width";
4
4
  interface ThresholdRule {
@@ -188,6 +188,11 @@ interface EvalContext {
188
188
  run: EvalRunTree;
189
189
  nodes: readonly EvalNode[];
190
190
  events: readonly TraceReadResult["events"][number][];
191
+ /**
192
+ * Reader warnings from the underlying {@link TraceReadResult}.
193
+ * Token budgets fail closed when evidence-discard warnings are present.
194
+ */
195
+ readerWarnings: readonly TraceReadWarning[];
191
196
  }
192
197
  declare function evalRun(input: EvalRunInput, options?: EvalRunOptions): Promise<EvalRunResult>;
193
198
  declare const checks: {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { TraceReadResult } from 'agent-inspect/readers';
1
+ import { TraceReadResult, TraceReadWarning } from 'agent-inspect/readers';
2
2
 
3
3
  type CircuitRuleId = "circuit.same-tool-repetition" | "circuit.same-args-repetition" | "circuit.max-loop-iterations" | "circuit.max-retries" | "circuit.tool-timeout" | "circuit.runaway-llm-loop" | "circuit.excessive-branch-width";
4
4
  interface ThresholdRule {
@@ -188,6 +188,11 @@ interface EvalContext {
188
188
  run: EvalRunTree;
189
189
  nodes: readonly EvalNode[];
190
190
  events: readonly TraceReadResult["events"][number][];
191
+ /**
192
+ * Reader warnings from the underlying {@link TraceReadResult}.
193
+ * Token budgets fail closed when evidence-discard warnings are present.
194
+ */
195
+ readerWarnings: readonly TraceReadWarning[];
191
196
  }
192
197
  declare function evalRun(input: EvalRunInput, options?: EvalRunOptions): Promise<EvalRunResult>;
193
198
  declare const checks: {
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { fileURLToPath } from 'url';
2
- import { openTrace, TraceReadError } from 'agent-inspect/readers';
2
+ import { projectLogicalEvents } from 'agent-inspect/checks';
3
+ import { openTrace, TraceReadError, isTraceEvidenceDiscardWarning } from 'agent-inspect/readers';
3
4
  import crypto, { createHash } from 'crypto';
4
5
 
5
6
  // packages/eval/src/index.ts
@@ -1423,7 +1424,8 @@ async function evalRun(input, options = {}) {
1423
1424
  format: resolved.read.format,
1424
1425
  run: selected.run,
1425
1426
  nodes: flatten(selected.run.children),
1426
- events: resolved.read.events.filter((event) => event.runId === selected.run?.runId)
1427
+ events: resolved.read.events.filter((event) => event.runId === selected.run?.runId),
1428
+ readerWarnings: resolved.read.warnings
1427
1429
  };
1428
1430
  const diagnostics = [];
1429
1431
  const findings = [];
@@ -1508,7 +1510,10 @@ function measuredTotalTokens(event) {
1508
1510
  return void 0;
1509
1511
  }
1510
1512
  function llmEventsForTokenBudget(events) {
1511
- return events.filter((event) => event.kind === "LLM");
1513
+ const { logicalEvents } = projectLogicalEvents(events);
1514
+ return logicalEvents.filter(
1515
+ (event) => event.kind === "LLM" && event.status !== "running"
1516
+ );
1512
1517
  }
1513
1518
  function createRule(id, category, evaluate) {
1514
1519
  return { id, category, severity: "error", evaluate };
@@ -1768,6 +1773,21 @@ var checks = {
1768
1773
  return createRule("eval.maxTotalTokens", "llm", (context) => {
1769
1774
  const llms = llmEventsForTokenBudget(context.events);
1770
1775
  const findings = [];
1776
+ if (context.readerWarnings.some(isTraceEvidenceDiscardWarning)) {
1777
+ findings.push(
1778
+ fail2(
1779
+ "eval.maxTotalTokens",
1780
+ `Unverifiable total token budget: malformed or invalid trace evidence was discarded while reading, so the total token limit cannot be verified.`,
1781
+ evidenceForRun(context.run, "tokenUsage.total"),
1782
+ "complete measurable total token evidence with no discarded rows",
1783
+ {
1784
+ reason: "unverifiable",
1785
+ discardedEvidence: true,
1786
+ calls: llms.length
1787
+ }
1788
+ )
1789
+ );
1790
+ }
1771
1791
  const missing = llms.filter((event) => measuredTotalTokens(event) === void 0);
1772
1792
  if (missing.length > 0) {
1773
1793
  const errored = missing.filter((event) => event.status === "error");