Skip to content

Conversation

@salma-elshafey
Copy link
Contributor

Description

Please add an informative description that covers that changes made by the pull request and link all relevant issues.

If an SDK is being regenerated based on a new API spec, a link to the pull request containing these API spec changes should be included above.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@salma-elshafey salma-elshafey requested a review from a team as a code owner January 28, 2026 10:26
Copilot AI review requested due to automatic review settings January 28, 2026 10:26
@github-actions github-actions bot added the Evaluation Issues related to the client library for Azure AI Evaluation label Jan 28, 2026
Copy link
Contributor

Copilot AI left a comment

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 fixes a bug in the agent response reformatting functionality for evaluators. The issue was that tool call arguments were always being formatted with quotes around them, regardless of their actual type. This caused non-string arguments (numbers, booleans, None, etc.) to be incorrectly displayed as strings.

Changes:

  • Added a new _format_value helper function to properly format different argument types
  • Updated _get_agent_response to use the new formatting function for tool call arguments

Comment on lines 712 to 718
def _format_value(v):
if isinstance(v, str):
return f'"{v}"'
elif v is None:
return 'None'
else:
return str(v)
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The _format_value function uses str() for complex types (dicts, lists), which produces Python-style representations (e.g., {'key': 'value'} instead of JSON-style {"key": "value"}). For tool call arguments that may contain nested structures, consider whether json.dumps() would be more appropriate to ensure consistent JSON-style formatting. This would produce output like ranking_options={"ranker": "default_2024_08_21", "score_threshold": 0.0} instead of ranking_options={'ranker': 'default_2024_08_21', 'score_threshold': 0.0}.

Copilot uses AI. Check for mistakes.
Comment on lines 712 to 718
def _format_value(v):
if isinstance(v, str):
return f'"{v}"'
elif v is None:
return 'None'
else:
return str(v)
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

This bug fix improves argument formatting in tool call messages, but test coverage should be expanded to verify the behavior with different argument types. Consider adding test cases to test__get_agent_response_with_tool_messages that verify formatting with:

  • Numeric arguments (integers and floats like score_threshold: 0.0)
  • Boolean arguments (e.g., enabled: true)
  • None/null values
  • Nested dictionaries (e.g., ranking_options: {"ranker": "default", "score_threshold": 0.0})

This would ensure the fix works correctly for all the data types that can appear in tool call arguments.

Copilot uses AI. Check for mistakes.
Comment on lines 712 to 718
def _format_value(v):
if isinstance(v, str):
return f'"{v}"'
elif v is None:
return 'None'
else:
return str(v)
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The _format_value helper function lacks a docstring explaining its purpose and behavior. Consider adding a docstring that describes:

  • The purpose: Format tool call argument values for display in agent response text
  • Parameter type and meaning
  • Return value and format
  • Examples of how different types are formatted (strings, numbers, None, booleans, complex types)

This would improve code maintainability and help other developers understand the formatting rules.

Copilot uses AI. Check for mistakes.
Comment on lines 712 to 718
def _format_value(v):
if isinstance(v, str):
return f'"{v}"'
elif v is None:
return 'None'
else:
return str(v)
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The _format_value function handles booleans using str(), which produces Python-style capitalized boolean strings ("True" or "False"). Consider whether lowercase booleans ("true" or "false") would be more appropriate for consistency with JSON conventions, especially since tool call arguments often originate from JSON data. If the current behavior is intentional for Python-style output, this is acceptable.

Copilot uses AI. Check for mistakes.
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