agent-inspect 6.31.35 → 6.31.36

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.
@@ -1,5 +1,5 @@
1
- import { extractSessionWorkflowMetadata, sessionKeyForRun, defineTraceContract, runTraceChecks, createRunStatusRule, createToolUsageRule, createRunDurationRule, createRunDepthRule, createToolFailureRule, createLlmUsageRule, createObservedOutcomeRule } from './chunk-3OMB34E6.mjs';
2
- export { extractSessionWorkflowMetadata, sessionKeyForRun } from './chunk-3OMB34E6.mjs';
1
+ import { extractSessionWorkflowMetadata, sessionKeyForRun, defineTraceContract, runTraceChecks, createRunStatusRule, createToolUsageRule, createRunDurationRule, createRunDepthRule, createToolFailureRule, createLlmUsageRule, createObservedOutcomeRule } from './chunk-KQX3Z4DH.mjs';
2
+ export { extractSessionWorkflowMetadata, sessionKeyForRun } from './chunk-KQX3Z4DH.mjs';
3
3
  export { MAX_TERMINAL_DEPTH, MAX_TERMINAL_NAME_LENGTH, TERMINAL_INDENT, TraceDirectory, createInspector, createInspectorRuntime, formatTerminalName, getCurrentContext, getCurrentCorrelationMetadata, getCurrentDepth, getCurrentRunId, getCurrentRunName, getCurrentStepId, getIndent, getParentStepId, getTraceDirFromContext, getTraceSafetyFromContext, hasActiveContext, isAgentInspectEnabled, isSilentContext, maybeInspectRun, printError, printFailedAt, printRunComplete, printRunStart, printStepComplete, printStepStart, renderErrorLine, renderRunSummary, renderStepLine, resolveTraceDir, runWithContext, runWithStepContext } from './chunk-X5RP2E2H.mjs';
4
4
  import { buildRunTimeline, filterTraces, extractMetadata, buildRunSummary } from './chunk-2SKAI5ZN.mjs';
5
5
  export { buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildTraceStats, extractMetadata, filterTraces, formatStepLabel, renderRunWhat, renderTimeline, renderTraceStats } from './chunk-2SKAI5ZN.mjs';
@@ -5336,6 +5336,9 @@ function createToolFailureRule(options) {
5336
5336
  }
5337
5337
  };
5338
5338
  }
5339
+ function recordsTokenUsage(event) {
5340
+ return Object.values(event.tokenUsage ?? {}).some((count) => typeof count === "number");
5341
+ }
5339
5342
  function createLlmUsageRule(options) {
5340
5343
  return {
5341
5344
  id: "llm.usage",
@@ -5393,6 +5396,21 @@ function createLlmUsageRule(options) {
5393
5396
  ["total", options.maxTotalTokens],
5394
5397
  ["cached", options.maxCachedTokens]
5395
5398
  ];
5399
+ const hasTokenLimit = tokenLimits.some(([, limit]) => limit !== void 0);
5400
+ const callsWithoutUsage = llms.filter(
5401
+ (event) => event.status !== "error" && !recordsTokenUsage(event)
5402
+ );
5403
+ if (hasTokenLimit && callsWithoutUsage.length > 0) {
5404
+ findings.push(
5405
+ failFinding(
5406
+ "llm.usage",
5407
+ `No token usage was read for ${callsWithoutUsage.length} of ${llms.length} LLM call(s), so the token limit cannot be verified.`,
5408
+ callsWithoutUsage.map((event) => eventEvidence3(event, "tokenUsage")),
5409
+ "token usage on every completed LLM call",
5410
+ { callsWithoutUsage: callsWithoutUsage.length, calls: llms.length }
5411
+ )
5412
+ );
5413
+ }
5396
5414
  for (const [key, limit] of tokenLimits) {
5397
5415
  if (limit !== void 0 && tokenTotals[key] > limit) {
5398
5416
  findings.push(