Skip to content

[Evaluation] Consolidate _get_tool_calls_results/_reformat_tool_calls_results into _common/utils.py#47842

Draft
m7md7sien with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-imports-in-tool-call-success
Draft

[Evaluation] Consolidate _get_tool_calls_results/_reformat_tool_calls_results into _common/utils.py#47842
m7md7sien with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-imports-in-tool-call-success

Conversation

Copilot AI commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

_tool_call_success.py defined its own _get_tool_calls_results and _reformat_tool_calls_results, duplicating (and diverging from) equivalent logic elsewhere. The two copies formatted tool-call arguments differently: _tool_call_success.py used f'{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 via json.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_value for args and _stringify_tool_result for results
    • _reformat_tool_calls_results: safe wrapper around _get_tool_calls_results with fallback on parse failure, logging via _log_safe_summary
  • _tool_call_success.py — Removed the 64-line duplicate definitions; imports _get_tool_calls_results and _reformat_tool_calls_results from _common/utils.py instead.

…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
Copilot AI requested a review from m7md7sien July 6, 2026 00:45
@m7md7sien

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Copilot AI and others added 2 commits July 6, 2026 19:57
Co-authored-by: m7md7sien <16615690+m7md7sien@users.noreply.github.com>
Co-authored-by: m7md7sien <16615690+m7md7sien@users.noreply.github.com>

Copilot AI commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Merge conflicts resolved in commit 84adef00.

  • _common/utils.py: accepted all new additions from main (_FAILED_RUNTIME_STATUSES, _coerce_bool, _coerce_number, _collect_failed_tool_calls, _get_conversation_history_with_tool_calls)
  • _tool_call_success.py: kept our version (duplicate _get_tool_calls_results/_reformat_tool_calls_results remain removed, imported from utils.py); also dropped the now-unused _stringify_tool_result import

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 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_results into _common/utils.py, using _format_value for arguments and JSON-based serialization for structured tool results.
  • Added _stringify_tool_result and _log_safe_summary helpers to improve prompt readability and prevent sensitive-data leakage in fallback logs.
  • Removed the duplicated implementations from _tool_call_success.py and 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants