evaluate() uses an unset hyperparameters value for cache lookups and writes
The cache sees a different hyperparameter value from the run report
evaluate() accepts hyperparameters so a test run can record the model, prompt, or other settings used for that evaluation. The local cache also includes those hyperparameters in its test-case key. That is useful when the same visible test case is evaluated under different configurations: the two runs should be able to keep separate cached results.
The current order of operations breaks that separation. evaluate() calls the synchronous or asynchronous test-case executor before it assigns the supplied hyperparameters to the TestRun. Both executors ask the cache manager for a result during execution, and the cache manager serializes test_run.hyperparameters into its key. The explicit value passed to evaluate() is assigned only after the executor returns. The resulting run can display the requested hyperparameters even though its cache lookup and cache write used an unset or previous value.
This is visible in evaluate.py: executor calls precede process_hyperparameters(hyperparameters). The cache reads the run value in e2e.py and includes it in the serialized key in cache.py.
How to reproduce
Use the same LLMTestCase and metric for two calls to evaluate(). Enable cache lookup with CacheConfig(use_cache=True), and pass {"model": "first"} to the first call and {"model": "second"} to the next. For a direct check that does not depend on a particular metric score, spy on global_test_run_cache_manager.get_cached_test_case and cache_test_case and inspect the hyperparameters argument each receives. On the current main branch, neither call receives the value supplied to the corresponding evaluate() invocation. The sync and async executors follow the same sequence.
A small offline case is enough: LLMTestCase(input="question", actual_output="answer", expected_output="answer") with ExactMatchMetric(). The problem is the cache identity passed to the manager, so no model or API request is needed to observe it.
Expected behavior
The cache lookup and write for the first run should use {"model": "first"}. The second should use {"model": "second"}. The values used for cache identity should agree with the hyperparameters recorded on each completed run, including when evaluations are accumulated with _skip_reset=True.
Why it matters
The cache key explicitly reserves a place for hyperparameters, but evaluate() does not populate that place in time. Two configurations can therefore compete for the same entry when the other key fields are equal. A cached metric result may be reused across configurations that callers intended to keep separate, while the run metadata makes the result appear to belong to the new configuration. That is especially hard to notice in repeated benchmark runs because the evaluation still completes normally.
Applying the supplied hyperparameters before entering either executor, then covering both sync and async cache reads and writes with a regression test, would keep the cache and run metadata in agreement.
Source: confident-ai/deepeval