Skip to content

fix(eval): validate ground-truth session ids - #2880

Open
1828703450qqcom-ux wants to merge 2 commits into
aws:v1.xfrom
1828703450qqcom-ux:fix/eval-ground-truth-session-validation
Open

1828703450qqcom-ux wants to merge 2 commits into
aws:v1.xfrom
1828703450qqcom-ux:fix/eval-ground-truth-session-validation

Conversation

@1828703450qqcom-ux

Copy link
Copy Markdown

Summary

  • Reject --ground-truth entries without a session ID in both on-demand references and batch session metadata, rather than silently ignoring or submitting malformed references.
  • Warn when on-demand ground-truth session IDs do not match sessions that receive any evaluation call.
  • Keep matching on-demand references attached to their session evaluation.

Closes #2876

Testing

  • bun test src/core/evalGroundTruth.test.ts — 4 passed; the broader on-demand test command reported by the contributor passed 25 tests.
  • bun run typecheck, bun run lint:check, bun run format:check, bun run build, and bun run secrets:check passed.
  • git diff --check passed.
  • The full suite was not completed on Windows: a keyring temporary-directory cleanup hit EBUSY. The local audit command could not run because the installed Bun version could not read this repository's lockfile version.

AI assistance: Codex helped implement and test this change.

@1828703450qqcom-ux
1828703450qqcom-ux requested a review from a team November 20, 2026 21:18
@github-actions github-actions Bot added the size/m PR size: M label Nov 20, 2026
@vivdalal

vivdalal commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

@1828703450qqcom-ux — Thanks for fixing the silent drop and for adding core tests for missing, matching, and unmatched session IDs. I checked the unmatched case with the CLI’s production file logger: the warning goes into the rotating log, but stderr is empty. A user looking at the evaluation result still can’t tell their ground truth was ignored.

Could you surface that warning on stderr and add a command-level regression test that asserts stderr names the unused session and stdout remains valid JSON? One useful case is a session that exists but has no tool-call spans for a tool-call evaluator: it should warn and make no Evaluate call.

I also hit internal TypeErrors with on-demand --ground-truth '[null]' (reading ref.context) and batch --ground-truth '{}' (calling .entries()). Could you validate the array and its entries before accessing them, and add regression tests for those two inputs? The errors should name --ground-truth and, for the null entry, identify entry 0.

@1828703450qqcom-ux

Copy link
Copy Markdown
Author

Thanks @vivdalal for the thorough review! Addressed all of the feedback in commit 72c7205:

  1. Surface unused --ground-truth session warnings on stderr: Added an optional onWarning callback to CoreEvalClient.evaluate and wired both eval ondemand evaluate and eval ondemand simulate through warn(io, message) so warnings reach stderr while stdout stays clean valid JSON.
  2. Validate --ground-truth arrays and entries before dereferencing:
    • Switched eval batch-evaluation evaluate to parseJsonArrayFlag (after resolving --ground-truth/--output-config stdin text so stdin conflict detection preserves flag order), rejecting non-array --ground-truth '{}' before any SDK call.
    • Added Array.isArray and plain-object entry guards in groupRefsBySession and startBatchEvaluation, returning InputValidationError naming --ground-truth and entry <index> (e.g. for [null]) before any SDK call.
  3. Command-level & core regression tests:
    • Added CLI command tests in ondemand.test.tsx (unmatched session warns on stderr with valid JSON stdout; existing session with no tool-call spans for a TOOL_CALL evaluator warns on stderr naming the session and makes 0 Evaluate calls; --ground-truth '[null]' rejects naming --ground-truth and entry 0).
    • Added CLI batch command test in batch-evaluation.test.tsx for --ground-truth '{}' plus corresponding evalGroundTruth.test.ts cases.

Verified locally with bun test src/core/evalGroundTruth.test.ts src/handlers/eval/ondemand/ondemand.test.tsx src/handlers/eval/batch-evaluation/batch-evaluation.test.tsx (54 pass, 0 fail), bun run typecheck, bun run lint:check (oxlint), and prettier --check.

@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels Dec 2, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eval ondemand evaluate: --ground-truth entries without spanContext.sessionId are silently dropped

2 participants