Draft
[Evaluation] Consolidate _get_tool_calls_results/_reformat_tool_calls_results into _common/utils.py#47842
Conversation
…ool_calls_results from _common/utils.py - Add _stringify_tool_result and _log_safe_summary to _common/utils.py - Add improved _get_tool_calls_results and _reformat_tool_calls_results to _common/utils.py (using _format_value and _stringify_tool_result for consistent arg/result formatting) - Remove duplicate local definitions from _tool_call_success.py - Import _get_tool_calls_results and _reformat_tool_calls_results from _common/utils.py in _tool_call_success.py Co-authored-by: m7md7sien <16615690+m7md7sien@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix imports in _tool_call_success.py
[Evaluation] Consolidate _get_tool_calls_results/_reformat_tool_calls_results into _common/utils.py
Jul 6, 2026
Contributor
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: m7md7sien <16615690+m7md7sien@users.noreply.github.com>
Co-authored-by: m7md7sien <16615690+m7md7sien@users.noreply.github.com>
Contributor
Author
Merge conflicts resolved in commit
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR consolidates tool-call extraction/formatting logic into azure.ai.evaluation._common.utils to eliminate duplication and ensure consistent argument/result rendering (including safe fallback logging that avoids leaking payload contents).
Changes:
- Centralized
_get_tool_calls_results/_reformat_tool_calls_resultsinto_common/utils.py, using_format_valuefor arguments and JSON-based serialization for structured tool results. - Added
_stringify_tool_resultand_log_safe_summaryhelpers to improve prompt readability and prevent sensitive-data leakage in fallback logs. - Removed the duplicated implementations from
_tool_call_success.pyand switched the evaluator to use the shared utilities.
Reviewed changes
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_common/utils.py | Adds canonical tool-call/result formatting plus safe-logging helpers and fallback behavior. |
| sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluators/_tool_call_success/_tool_call_success.py | Removes local duplicated formatter implementations and imports the shared utilities instead. |
| from azure.ai.evaluation._common.utils import _log_safe_summary, _stringify_tool_result | ||
| from azure.ai.evaluation._common.utils import _log_safe_summary | ||
| from azure.ai.evaluation._common._experimental import experimental | ||
| from azure.ai.evaluation._common.utils import _get_tool_calls_results, _reformat_tool_calls_results |
m7md7sien
approved these changes
Jul 12, 2026
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.
_tool_call_success.pydefined its own_get_tool_calls_resultsand_reformat_tool_calls_results, duplicating (and diverging from) equivalent logic elsewhere. The two copies formatted tool-call arguments differently:_tool_call_success.pyusedf'{k}="{v}"'(all values quoted), while the utils path used_format_value(v)(numbers unquoted,None→"None").Changes
_common/utils.py— Added:_stringify_tool_result: renders tool results as LLM-readable strings (list/dict → JSON viajson.dumps,None→"", str passthrough)_log_safe_summary: shape-only structural summary for safe logging (avoids leaking PII/customer data into telemetry)_get_tool_calls_results: canonical implementation using_format_valuefor args and_stringify_tool_resultfor results_reformat_tool_calls_results: safe wrapper around_get_tool_calls_resultswith fallback on parse failure, logging via_log_safe_summary_tool_call_success.py— Removed the 64-line duplicate definitions; imports_get_tool_calls_resultsand_reformat_tool_calls_resultsfrom_common/utils.pyinstead.