nemo_voice_agent.evaluation.db_hash
nemo_voice_agent.evaluation.db_hash
Utilities for computing hashes and structured diffs of scenario DB states.
Used by the eva-style “DB-state hash matching” scoring mode (see
docs/evaluate/domain-guides/eva-airline.md): hash the post-run DB and
the expected DB; if they differ, compute_db_diff produces a tables →
records → fields diff for human debugging.
Path-independent scoring: any sequence of agent actions that lands in the right end state passes, regardless of how the agent got there.
Module Contents
Functions
Data
API
Recursively diff two record values; returns None if identical.
Diff between two dict-valued tables; returns None if identical.
Compute a structured diff between expected and actual DB states.
Adapted from https://github.com/ServiceNow/eva/tree/0.1.3.
Returned dict has shape::
{ “tables_added”: [name, …], # in actual but not expected “tables_removed”: [name, …], # in expected but not actual “tables_modified”: {table_name: {records_added, records_removed, records_modified}}, }
Used for human debugging when get_dict_hash(expected) != get_dict_hash(actual).
Not used for scoring itself (the hash comparison is the verdict).
Compute SHA-256 hash of a dict (canonical JSON serialization).
Adapted from https://github.com/ServiceNow/eva/tree/0.1.3.
Follows tau-2 bench’s approach:
- Drop keys in
HASH_EXCLUDED_KEYS(e.g.session) from the top level. - Normalize via
normalize_for_comparisonso float/int and “none”/None don’t cause false mismatches. - Serialize with
sort_keys=True, no whitespace,default=strfor non-JSON-serializable types. - SHA-256 of the resulting string.
Recursively normalize values for consistent comparison and hashing.
Adapted from https://github.com/ServiceNow/eva/tree/0.1.3 — verbatim.
Normalizations applied:
- float → int when the value is a whole number and finite (e.g. 1.0 → 1)
- “none” / “null” string → None (case-insensitive, stripped)
- Recurse into dict values and list elements
- Lists under
ORDER_INDEPENDENT_LIST_FIELDSare sorted before serialization so element ordering doesn’t affect hashes.
Eliminates common false-mismatches between the agent’s DB and the expected
DB (e.g. one side stores 1 and the other 1.0).