fix: include tool and trace state in evaluation cache keys#2561
Open
aerosta wants to merge 1 commit intoconfident-ai:mainfrom
Open
fix: include tool and trace state in evaluation cache keys#2561aerosta wants to merge 1 commit intoconfident-ai:mainfrom
aerosta wants to merge 1 commit intoconfident-ai:mainfrom
Conversation
|
@aerosta is attempting to deploy a commit to the Confident AI Team on Vercel. A member of the Team first needs to authorize it. |
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
The evaluation cache key originally only considered the text fields on
LLMTestCase:input,actual_output,expected_output,context, andretrieval_context.For tool-based and trace-based evaluation, that was incomplete. Metrics such as
ToolCorrectnessMetricand trace-level metrics also depend on execution-state fields liketools_called,expected_tools, MCP call data, and_trace_dict. Two test cases with the same text but different tool calls or trace structure could therefore produce the same cache key and reuse stale metric results.This change moves cache key construction into
CachedTestCase.create_cache_key()and includes the execution-state fields that affect scoring.Changes
CachedTestCase.create_cache_key()indeepeval/test_run/cache.pyget_cached_test_case()andcache_test_case()Context
Tool-calling and trace-level metrics evaluate fields such as
tools_called,expected_tools, and_trace_dict. Because those fields were not part of the cache key, changing only the execution state between runs could still return cached scores from a previous run.This updates the cache key format, so existing cache entries will miss on the first run after upgrade. That is intentional, a one-time re-evaluation is safer than serving stale results.
Tests
tests/test_core/test_run/test_cache_keys.py