Skip to content

azure-ai-agents and azure-ai-projects TSP union types addressed#48352

Open
jpalvarezl wants to merge 18 commits intomainfrom
jpalvarezl/fix/union_types
Open

azure-ai-agents and azure-ai-projects TSP union types addressed#48352
jpalvarezl wants to merge 18 commits intomainfrom
jpalvarezl/fix/union_types

Conversation

@jpalvarezl
Copy link
Member

This pull request introduces union type support for several model classes in the Azure AI Agents SDK, enabling more flexible property handling and simplifying usage. The most significant changes are the addition of overloaded getter and setter methods for properties that can accept or return multiple types, and updates to sample code to use the new API. These improvements make the SDK easier to use and extend, especially when working with properties that can represent different data formats.

Union type support for model properties:

  • Added overloaded getter and setter methods for union-type properties in CodeInterpreterTool, ComparisonFilter, FileSearchTool, and McpTool, allowing these properties to be set and retrieved as different types (e.g., String, object, list, boolean, number). [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

API simplification and improved usability:

  • Changed previous generic BinaryData getter/setter methods to internal/private, and replaced them with public methods for specific types, improving clarity and reducing the need for manual serialization. [1] [2] [3] [4] [5]

Sample code updates:

  • Updated sample files to use the new, simplified setter methods for union-type properties, removing direct BinaryData usage and replacing it with native types (e.g., setRequireApproval("never")). [1] [2] [3] [4]

Code cleanup:

  • Removed unnecessary imports of BinaryData from sample files, reflecting the new API design. [1] [2] [3] [4]

General enhancements:

  • Added comments and documentation clarifying union type support and usage in affected model classes. [1] [2] [3] [4]

These changes collectively make the SDK more robust and developer-friendly when dealing with properties that can represent multiple types.

Base automatically changed from jpalvarezl/fix/type_overrides to main March 10, 2026 14:20
@github-actions
Copy link
Contributor

github-actions bot commented Mar 10, 2026

API Change Check

APIView identified API level changes in this PR and created the following API reviews

com.azure:azure-ai-agents

Copilot AI review requested due to automatic review settings March 11, 2026 09:08
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 refines the public Java API for several AI Agents “union-type” tool properties (previously exposed as BinaryData) by adding typed setters/getters, and updates tests/samples accordingly. It also introduces new serialization-focused unit tests to validate these union-type behaviors.

Changes:

  • Replaced BinaryData-based usage of requireApproval in MCP examples/tests with String overloads.
  • Added typed union accessors for MCP tool (allowedTools, requireApproval), File Search tool (filters), Code Interpreter tool (container), and ComparisonFilter (value), while making the raw BinaryData accessors internal-only.
  • Added new model serialization tests for MCP tool, File Search tool filters, Code Interpreter tool container, and ComparisonFilter value unions.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/models/McpTool.java Adds typed union accessors for allowedTools/requireApproval and updates API surface away from public BinaryData.
sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/models/FileSearchTool.java Adds typed union accessors for filters and makes raw BinaryData access internal-only.
sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/models/CodeInterpreterTool.java Adds typed union accessors for container and makes raw BinaryData access internal-only.
sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/models/ComparisonFilter.java Adds typed constructors/getters for union value and hides the BinaryData constructor.
sdk/ai/azure-ai-agents/src/test/java/com/azure/ai/agents/ToolsTests.java Updates MCP end-to-end test to use setRequireApproval("always").
sdk/ai/azure-ai-agents/src/test/java/com/azure/ai/agents/ToolsAsyncTests.java Updates MCP async end-to-end test to use setRequireApproval("always").
sdk/ai/azure-ai-agents/src/test/java/com/azure/ai/agents/models/McpToolSerializationTests.java New serialization/deserialization coverage for MCP union fields.
sdk/ai/azure-ai-agents/src/test/java/com/azure/ai/agents/models/FileSearchToolSerializationTests.java New serialization/deserialization coverage for FileSearchTool filters union.
sdk/ai/azure-ai-agents/src/test/java/com/azure/ai/agents/models/ComparisonFilterSerializationTests.java New serialization/deserialization coverage for ComparisonFilter value union.
sdk/ai/azure-ai-agents/src/test/java/com/azure/ai/agents/models/CodeInterpreterToolSerializationTests.java New serialization/deserialization coverage for CodeInterpreterTool container union.
sdk/ai/azure-ai-agents/src/samples/java/com/azure/ai/agents/tools/McpSync.java Updates MCP sample to use setRequireApproval("always") and removes BinaryData import.
sdk/ai/azure-ai-agents/src/samples/java/com/azure/ai/agents/tools/McpAsync.java Updates MCP sample to use setRequireApproval("always") and removes BinaryData import.
sdk/ai/azure-ai-agents/src/samples/java/com/azure/ai/agents/tools/McpWithConnectionSync.java Updates MCP-with-connection sample to use setRequireApproval("always") and removes BinaryData import.
sdk/ai/azure-ai-agents/src/samples/java/com/azure/ai/agents/tools/McpWithConnectionAsync.java Updates MCP-with-connection sample to use setRequireApproval("always") and removes BinaryData import.
sdk/ai/azure-ai-agents/src/samples/java/com/azure/ai/agents/tools/CustomCodeInterpreterSync.java Updates custom MCP code interpreter sample to use setRequireApproval("never") and removes BinaryData import.
sdk/ai/azure-ai-agents/src/samples/java/com/azure/ai/agents/tools/CustomCodeInterpreterAsync.java Updates custom MCP code interpreter sample to use setRequireApproval("never") and removes BinaryData import.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants