Skip to content

[Evaluation] Align shared evaluator utils/validators/base with azureml-assets builtin#47840

Open
m7md7sien wants to merge 1 commit into
Azure:mainfrom
m7md7sien:mohessie/evaluators-utils-parity
Open

[Evaluation] Align shared evaluator utils/validators/base with azureml-assets builtin#47840
m7md7sien wants to merge 1 commit into
Azure:mainfrom
m7md7sien:mohessie/evaluators-utils-parity

Conversation

@m7md7sien

@m7md7sien m7md7sien commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Description

Backports the changes where the azureml-assets builtin evaluators are ahead of / diverged from the shared azure-ai-evaluation code, so the builtin evaluators can eventually import these symbols directly from the SDK instead of inlining private copies. Grouped as buckets C (reconcile diverged shared code), D (PII-safe logging), and E (additive helpers) from the parity analysis.

Bucket C — reconcile diverged shared code

  • _normalize_function_call_types (_evaluators/_common/_base_prompty_eval.py): also normalize openapi_call / openapi_call_outputtool_call / tool_result (kept the existing function_call key-rename, so this is a strict superset). This also unblocks importing the widely-used _preprocess_messages.
  • _get_agent_response (_common/utils.py): render tool results via the new _stringify_tool_result, so list/dict grounding-tool outputs (Azure AI Search, SharePoint, Fabric) are readable JSON instead of a Python repr. Plain string results are unchanged → backward compatible.
  • _get_conversation_history / reformat_conversation_history: new opt-in include_tool_calls path that renders tool calls/results inline. Default behavior is unchanged.

Bucket D — PII-safe fallback logging

  • reformat_agent_response, reformat_conversation_history, and reformat_tool_definitions now emit richer, structural-only fallback summaries via the new _log_safe_summary (never raw payloads).

Bucket E — additive shared helpers

  • New in _common/utils.py: _stringify_tool_result, _log_safe_summary, _coerce_bool, _coerce_number, _collect_failed_tool_calls, _get_tool_calls_results, _reformat_tool_calls_results.
  • EvaluationLevel already exists in _common/constants.pynot re-added.
  • Instead of vendoring _create_extended_error_target, added the missing ErrorTarget members: QUALITY_GRADER_EVALUATOR, CUSTOMER_SATISFACTION_EVALUATOR, DEFLECTION_RATE_EVALUATOR, REGEX_MATCH_EVALUATOR (the other extended names already existed).

Testing

  • Added unit tests: TestToolResultAndLoggingHelpers in test_utils.py and an OpenAPI preprocessing test in test_multi_turn_utilities.py. Pre-existing OpenAPI-normalization tests now pass.
  • test_multi_turn_utilities.py, test_common_validators.py, test_utils.py: 201 passed.
  • Affected evaluator suites (agent / groundedness / task / tool): 92 passed.
  • black (24.4.0, repo config) clean.

Notes

  • All shared-function changes are backward-compatible supersets; no existing evaluator behavior changes except the two intentional ones above (OpenAPI normalization + mid-execution guard).

@github-actions github-actions Bot added the Evaluation Issues related to the client library for Azure AI Evaluation label Jul 5, 2026
@m7md7sien m7md7sien force-pushed the mohessie/evaluators-utils-parity branch 2 times, most recently from 445bd64 to 17134a7 Compare July 5, 2026 22:58
…ets builtin

Backport parity changes so azureml-assets builtin evaluators can import shared code from the SDK instead of inlining overrides:

- _normalize_function_call_types: also normalize openapi_call/openapi_call_output

- _extract_needed_tool_definitions: conditional OpenAPI functions expansion - expand nested functions when present, else keep the top-level def (incorporates Azure#46236)

- _get_agent_response + tool_call_success _get_tool_calls_results: render tool results as JSON via _stringify_tool_result (grounding tools); strings unchanged

- reformat_* helpers + Groundedness context extraction + tool_call_success reformat helpers: stop logging raw payloads in fallback/debug paths via _log_safe_summary (incorporates Azure#5158)

- _get_conversation_history/reformat_conversation_history: opt-in include_tool_calls inline rendering

- Add shared helpers: _stringify_tool_result, _log_safe_summary, _coerce_bool, _coerce_number, _collect_failed_tool_calls, _get_tool_calls_results, _reformat_tool_calls_results

- ErrorTarget: add QUALITY_GRADER/CUSTOMER_SATISFACTION/DEFLECTION_RATE/REGEX_MATCH members

Adds unit tests; black (24.4.0) clean.
@m7md7sien m7md7sien force-pushed the mohessie/evaluators-utils-parity branch from 17134a7 to 68a4dc8 Compare July 5, 2026 23:15
@m7md7sien m7md7sien requested a review from Copilot July 6, 2026 00:20
@m7md7sien m7md7sien marked this pull request as ready for review July 6, 2026 00:20
@m7md7sien m7md7sien requested a review from a team as a code owner July 6, 2026 00:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR backports shared evaluator utilities in azure-ai-evaluation so they align with the divergent azureml-assets builtin evaluators, enabling the builtin evaluators to eventually import these symbols directly from the SDK. It reconciles diverged shared code (OpenAPI normalization/expansion, JSON-rendered tool results), makes fallback/debug logging PII-safe, and adds new additive helpers. All shared-function changes are described as backward-compatible supersets.

Changes:

  • Bucket C: _normalize_function_call_types now also maps openapi_call/openapi_call_outputtool_call/tool_result; _extract_needed_tool_definitions expands OpenAPI tools into nested functions when present; _get_agent_response/conversation-history helpers render tool results as JSON via the new _stringify_tool_result and add an opt-in include_tool_calls path.
  • Bucket D: fallback/debug logging in reformat helpers and Groundedness now emits structural-only summaries via _log_safe_summary, never raw payloads.
  • Bucket E: new shared helpers (_stringify_tool_result, _log_safe_summary, _coerce_bool, _coerce_number, _collect_failed_tool_calls, _get_tool_calls_results, _reformat_tool_calls_results) plus 4 new ErrorTarget members.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
_common/utils.py Adds the new shared helpers, include_tool_calls conversation path, JSON tool-result rendering, and PII-safe fallback logging.
_evaluators/_common/_base_prompty_eval.py Extends _normalize_function_call_types for OpenAPI types and rewrites OpenAPI tool-definition expansion; removes now-unused chain import.
_evaluators/_tool_call_success/_tool_call_success.py Uses _stringify_tool_result and switches fallback logs to _log_safe_summary.
_evaluators/_groundedness/_groundedness.py Replaces payload-logging debug line with a count-only summary.
_exceptions.py Adds four new ErrorTarget enum members for parity.
CHANGELOG.md Documents the OpenAPI fix and the "Other Changes" (normalization, JSON tool results, PII-safe logging).
tests/unittests/test_utils.py Adds TestToolResultAndLoggingHelpers covering the new helpers and ErrorTarget members.
tests/unittests/test_tool_call_success_logging.py New tests asserting fallback paths don't leak raw payloads.
tests/unittests/test_tool_call_accuracy_evaluator.py Adds OpenAPI tool-definition expansion/validation tests.
tests/unittests/test_multi_turn_utilities.py Adds an OpenAPI normalization preprocessing test.

Notes on findings: The description's Bucket C MessagesOrQueryResponseInputValidator mid-execution guard (and the associated test_last_message_tool_role_accepted update) is not present in the diff or the current code, and the two _get_tool_calls_results/_reformat_tool_calls_results copies now diverge in argument formatting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Evaluation Issues related to the client library for Azure AI Evaluation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants