azure-ai-agents and azure-ai-projects TSP union types addressed#48352
Open
jpalvarezl wants to merge 18 commits intomainfrom
Open
azure-ai-agents and azure-ai-projects TSP union types addressed#48352jpalvarezl wants to merge 18 commits intomainfrom
azure-ai-agents and azure-ai-projects TSP union types addressed#48352jpalvarezl wants to merge 18 commits intomainfrom
Conversation
dargilco
approved these changes
Mar 10, 2026
Contributor
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
Contributor
There was a problem hiding this comment.
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 ofrequireApprovalin MCP examples/tests withStringoverloads. - Added typed union accessors for MCP tool (
allowedTools,requireApproval), File Search tool (filters), Code Interpreter tool (container), and ComparisonFilter (value), while making the rawBinaryDataaccessors 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. |
sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/models/McpTool.java
Show resolved
Hide resolved
sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/models/McpTool.java
Show resolved
Hide resolved
sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/models/CodeInterpreterTool.java
Outdated
Show resolved
Hide resolved
...ure-ai-agents/src/test/java/com/azure/ai/agents/models/FileSearchToolSerializationTests.java
Outdated
Show resolved
Hide resolved
sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/models/FileSearchTool.java
Outdated
Show resolved
Hide resolved
sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/models/CodeInterpreterTool.java
Show resolved
Hide resolved
sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/models/ComparisonFilter.java
Show resolved
Hide resolved
sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/models/ComparisonFilter.java
Outdated
Show resolved
Hide resolved
kaylieee
approved these changes
Mar 11, 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.
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:
CodeInterpreterTool,ComparisonFilter,FileSearchTool, andMcpTool, 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:
BinaryDatagetter/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:
BinaryDatausage and replacing it with native types (e.g.,setRequireApproval("never")). [1] [2] [3] [4]Code cleanup:
BinaryDatafrom sample files, reflecting the new API design. [1] [2] [3] [4]General enhancements:
These changes collectively make the SDK more robust and developer-friendly when dealing with properties that can represent multiple types.