feat(evaluators): add FuzzyEquals deterministic evaluator - #387
Draft
lifelmy wants to merge 1 commit into
Draft
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
lifelmy
requested a deployment
to
manual-approval
August 31, 2026 21:22 — with
GitHub Actions
Waiting
lifelmy
requested a deployment
to
manual-approval
August 31, 2026 21:22 — with
GitHub Actions
Waiting
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.
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.