Files
langsmith-java/langsmith-java-core/src
Emil Filipov 714a32cc62 fix(evaluation): don't post comparative feedback without a session_id (#52)
`logComparativeEvaluationFeedback` looked each run up by the keys of the
score map
returned by the user's comparative evaluator, but posted the feedback
whether or not
the lookup hit. On a miss, `POST /api/v1/feedback` went out with a
`run_id` but no
`session_id` — while still carrying this comparison's
`comparative_experiment_id` and
`feedback_group_id`. `ComparisonEvaluationResult.scores` is authored
entirely by the
evaluator and was never checked against the runs it was handed, so a
nested run id, or
one an LLM judge invented, was enough to trigger it.

Such an entry is now skipped with a `WARNING`, and `.sessionId(...)` is
unconditional in
the builder. No fallback session is used: with two experiments in play
there is no way to
tell which one an unrecognised run belongs to. Evaluator-supplied text
is sanitized before
logging so a judge's output can't forge log records.

The other feedback paths were checked and are unaffected — `evaluate()`
supplies
`session_id` via `TraceConfig`, and `evaluateExisting()` via the
required
`RunSchema.session_id`.

New `EvaluateSupportTest` calls the internal helper directly with a
mocked
`FeedbackService`. This path had no coverage before.

## Test Plan

- [x] `./gradlew :langsmith-java-core:test` green (422 test classes);
`lintKotlin` clean
2026-07-30 13:02:06 +02:00
..