Repository navigation
Conversation
Add FuzzyEquals, a configurable deterministic evaluator that compares expected and actual output with fuzzy matching options: - numeric_tolerance for approximate numeric comparison - ignore_order / ignore_key_order for lists and dict keys - case_sensitive and ignore_whitespace for strings - subset_mode to match a subset of an expected mapping/sequence - type_coercion for loose scalar comparison Uses a module sentinel for the expected value so an explicit expected value of None is distinguishable from an unset default. Closes strands-agents/harness-sdk#3727
|
Task A base refresh: merged current |
|
Task A base refresh: merged current |
…sks/3727 Co-authored-by: TRAE CLI <traecli@bytedance.com>
…sks/3727 Co-authored-by: TRAE CLI <traecli@bytedance.com> # Conflicts: # src/strands_evals/evaluators/__init__.py
|
Task A base refresh: merged the latest This was a real export conflict in Verification on the refreshed head:
I use a coding assistant to help implement, and I review and take responsibility for the final change. |
…sks/3727 Co-authored-by: TRAE CLI <traecli@bytedance.com>
…sks/3727 Co-authored-by: TRAE CLI <traecli@bytedance.com>
…sks/3727 Co-authored-by: TRAE CLI <traecli@bytedance.com>
Description
Adds
FuzzyEquals, a configurable deterministic evaluator for comparing structured outputs where exact matching is too brittle. Addresses strands-agents/harness-sdk#3727.The existing deterministic evaluators (
Equals,Contains,StartsWith) only do exact matching, which fails for SQL result sets, JSON objects, tabular data, and numeric computations where row/key order, numeric precision, or whitespace shouldn't decide a pass.FuzzyEqualscomparesactual_outputagainst an expected value recursively across lists and dicts, applying configurable knobs at every level.Knobs (matching the issue proposal)
ignore_order— treat lists as multisets so element order does not matterignore_key_order— dict key/value pairs must match regardless of insertion order (defaultTrue)numeric_tolerance— relative tolerance for numeric values (0.01accepts +/-1%)case_sensitive— case-insensitive string comparison whenFalseignore_whitespace— strip and collapse internal whitespace before comparingsubset_mode— pass if the expected value is contained in actual (actual ⊇ expected)type_coercion— numeric/boolean strings compare equal to numbers/booleans ("42" == 42)Follows the existing
Evaluator[InputT, OutputT]pattern and returns anEvaluationOutputwith a detailed diff path in thereasonfield (e.g.at $.rows[0].total: numbers differ ...). A module sentinel distinguishes an explicitvalue=Nonefrom the "compare againstexpected_output" default — somethingEqualscannot currently do.Testing
hatch fmt --formatter --check— 362 files already formattedhatch fmt --linter— all checks passedmypy -p src(hatch-static-analysis env) — Success: no issues found in 236 source filespytest tests/strands_evals/evaluators/deterministic/— 114 passed (44 new FuzzyEquals tests, no regressions)Notes
I use a coding assistant to help implement, and I review and take responsibility for the final change.
Marking as Draft for maintainer feedback on the API surface and whether the recursive implementation (vs. the
deepdiffalternative mentioned in the issue) is preferred before finalizing.Related Issue
strands-agents/harness-sdk#3727
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.