Commit 4cefc1c
Keep ToolCall hashable when output/inputs hold unhashable objects (#2815)
ToolCorrectnessMetric places ToolCall instances into a set during
component-level evaluation. ToolCall.__hash__ routes input_parameters and
output through _make_hashable, whose final branch returned arbitrary objects
unchanged, assuming they were primitive hashable types. When the output (or a
value nested in input_parameters) is an unhashable object, such as a LangChain
ToolMessage or a pydantic model that defines __eq__ without __hash__, hashing
raised `TypeError: unhashable type`, breaking evals_iterator() on agent traces.
Fall back to a stable repr() for any value that is not hashable. Primitives and
already-hashable objects are returned unchanged. Adds a regression test
covering an unhashable object both as the output and nested in input_parameters.
Closes #2815
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 8ebfa33 commit 4cefc1c
2 files changed
Lines changed: 47 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
232 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
233 | 242 | | |
234 | 243 | | |
235 | 244 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
450 | 450 | | |
451 | 451 | | |
452 | 452 | | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
453 | 490 | | |
454 | 491 | | |
455 | 492 | | |
| |||
0 commit comments