Repository navigation
feat(eval): provide preceding conversation context for rubric evaluat… - #283
Open
sowndappan5 wants to merge 1 commit into
Open
sowndappan5 wants to merge 1 commit into
sowndappan5 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
This PR Fixes #253.
When evaluating a multi turn conversation with
rubric_based_final_response_quality_v1, turns were evaluated in complete isolation. As a result, when an assistant response in later turn (ex: Turn 2) relied on facts, preferences or corrections from an earlier turn (ex: Turn 1) the LLM judge treated those earlier details as unsupported or failed to verify that the latest preference was honored. This PR adds preceding conversation context (turns0..i-1) to turni's judge prompt while strictly excluding future turns (i+1...) to prevent leakage.Problem & Reproduction
In a multi-turn flow:
The judge prompt for Turn 2 only contained
<user_prompt>for Turn 2 because"Paris"and original"Monday"were absent from Turn 2's prompt and the judge marked"Paris"as ungrounded/unsupported evidence and returnedVerdict: no.Changes I made
src/agentevals/judges.py:format_preceding_dialogue(invocations): formats preceding turns (0..i-1) into readable context including user prompts, assistant replies and intermediate tool calls._RUBRIC_FINAL_RESPONSE_WITH_HISTORY_PROMPT: updates the evaluation preamble and template to include<preceding_conversation>as trusted evidence alongside<user_prompt>and<response_steps>.RubricBasedFinalResponseQualityV1WithHistory: overridesevaluate_invocationsto map each invocation to its preceding slice (actual_invocations[:i]) and injects it intoformat_auto_rater_prompt, cleaning up after evaluation.src/agentevals/builtin_metrics.py:rubric_based_final_response_quality_v1in_DIRECT_EVALUATORSto route toRubricBasedFinalResponseQualityV1WithHistory.tests/test_rubrics.py:TestPrecedingConversationContextwith tests verifying:"None (this is the first turn).").Testing & Verification
All checks and tests pass locally:
uv run ruff check src/agentevals/judges.py src/agentevals/builtin_metrics.py tests/test_rubrics.py #All checks passed!uv run pytest tests/test_rubrics.py -q #31 passed in 3.91s (all 29 existing test+2 new regression test)uv run pytest tests/test_layering.py -q #2 passed in 0.24suv run pytest tests/test_rubrics.py tests/test_builtin_metrics.py tests/test_adk_bridge.py tests/test_runner.py -q #102 passed in 15.00sChecklist
uv run pytest)