Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions sdk/ai/azure-ai-agents/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@
- Added `readSpecFromFile(Path)` static convenience method to `OpenApiFunctionDefinition` for loading OpenAPI specification JSON files as the `Map<String, BinaryData>` required by the constructor, eliminating the need for manual `JsonReader`/`BinaryData` wiring.
- Added new `OpenApiSync`/`OpenApiAsync` samples demonstrating end-to-end OpenAPI tool integration: loading a spec file, creating an agent with an `OpenApiTool`, and invoking an external API via conversation.
- Added new tool samples for parity with the Python SDK: `AzureFunctionSync`/`AzureFunctionAsync`, `BingCustomSearchSync`/`BingCustomSearchAsync`, `MemorySearchSync`/`MemorySearchAsync`, `McpWithConnectionSync`/`McpWithConnectionAsync`, and `OpenApiWithConnectionSync`/`OpenApiWithConnectionAsync`.
- Added type-safe accessors on `CodeInterpreterTool` for the `container` property: `setContainer(String)`, `setContainer(AutoCodeInterpreterToolParam)`, `getContainerAsString()`, and `getContainerAsAutoCodeInterpreterToolParam()`.
- Added type-safe accessors on `McpTool` for the `allowedTools` property: `setAllowedTools(List<String>)`, `setAllowedTools(McpToolFilter)`, `getAllowedToolsAsStringList()`, and `getAllowedToolsAsMcpToolFilter()`.
- Added type-safe accessors on `McpTool` for the `requireApproval` property: `setRequireApproval(String)`, `setRequireApproval(McpToolRequireApproval)`, `getRequireApprovalAsString()`, and `getRequireApprovalAsMcpToolRequireApproval()`.
- Added `setComparisonFilter(ComparisonFilter)` and `setCompoundFilter(CompoundFilter)` convenience methods on `FileSearchTool`, accepting the openai-java filter types directly.

### Breaking Changes

- `AgentDefinitionOptInKeys` and `FoundryFeaturesOptInKeys` changed from `ExpandableStringEnum`-based classes to standard Java `enum` types. The `values()` method now returns an array instead of a `Collection`, and the deprecated no-arg constructor is removed.
- The `timezone` property in `ApproximateLocation` and `WebSearchApproximateLocation` changed from `String` to `java.util.TimeZone`.
- The `container` property on `CodeInterpreterTool` no longer exposes `BinaryData` getter/setter publicly. Use the new typed accessors instead (e.g., `setContainer("container-id")` or `setContainer(new AutoCodeInterpreterToolParam())`).
- The `allowedTools` and `requireApproval` properties on `McpTool` no longer expose `BinaryData` getter/setter publicly. Use the new typed accessors instead (e.g., `setRequireApproval("always")` or `setAllowedTools(List.of("tool_a", "tool_b"))`).
- The `filters` property on `FileSearchTool` no longer exposes `BinaryData` getter/setter publicly.
- The `reasoning` property on `PromptAgentDefinition` now uses `com.openai.models.Reasoning` from the openai-java library instead of the previously generated `Reasoning` class. Use `Reasoning.builder().effort(ReasoningEffort.HIGH).build()` to construct values.
- Removed `ComparisonFilter`, `ComparisonFilterType`, `CompoundFilter`, `CompoundFilterType`, `Reasoning`, `ReasoningEffort`, `ReasoningSummary`, and `ReasoningGenerateSummary` from `com.azure.ai.agents.models`. Use the equivalent types from `com.openai.models` instead (e.g., `com.openai.models.ComparisonFilter`, `com.openai.models.Reasoning`).

Expand Down
4 changes: 2 additions & 2 deletions sdk/ai/azure-ai-agents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ Connect agents to external MCP servers:
// Uses gitmcp.io to expose a GitHub repository as an MCP-compatible server
McpTool tool = new McpTool("api-specs")
.setServerUrl("https://gitmcp.io/Azure/azure-rest-api-specs")
.setRequireApproval(BinaryData.fromObject("always"));
.setRequireApproval("always");
```

See the full sample in [McpSync.java](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/ai/azure-ai-agents/src/samples/java/com/azure/ai/agents/tools/McpSync.java).
Expand Down Expand Up @@ -536,7 +536,7 @@ MCP integration using project-specific connections for accessing connected MCP s
McpTool mcpTool = new McpTool("api-specs")
.setServerUrl("https://api.githubcopilot.com/mcp")
.setProjectConnectionId(mcpConnectionId)
.setRequireApproval(BinaryData.fromObject("always"));
.setRequireApproval("always");
```

See the full sample in [McpWithConnectionSync.java](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/ai/azure-ai-agents/src/samples/java/com/azure/ai/agents/tools/McpWithConnectionSync.java).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public ToolType getType() {
*
* @return the container value.
*/
@Generated
public BinaryData getContainer() {
BinaryData getContainer() {
// AI Tooling: union type
return this.container;
}

Expand Down Expand Up @@ -117,9 +117,71 @@ public CodeInterpreterTool() {
* @param container the container value to set.
* @return the CodeInterpreterTool object itself.
*/
@Generated
public CodeInterpreterTool setContainer(BinaryData container) {
CodeInterpreterTool setContainer(BinaryData container) {
// AI Tooling: union type
this.container = container;
return this;
}

/**
* Set the container property: The code interpreter container. Can be a container ID or an object that
* specifies uploaded file IDs to make available to your code, along with an
* optional `memory_limit` setting.
* If not provided, the service assumes auto.
*
* @param containerId the container ID string to set.
* @return the CodeInterpreterTool object itself.
*/
public CodeInterpreterTool setContainer(String containerId) {
// AI Tooling: union type
this.container = BinaryData.fromString(containerId);
return this;
}

/**
* Set the container property: The code interpreter container. Can be a container ID or an object that
* specifies uploaded file IDs to make available to your code, along with an
* optional `memory_limit` setting.
* If not provided, the service assumes auto.
*
* @param container the {@link AutoCodeInterpreterToolParam} to set.
* @return the CodeInterpreterTool object itself.
*/
public CodeInterpreterTool setContainer(AutoCodeInterpreterToolParam container) {
// AI Tooling: union type
this.container = BinaryData.fromObject(container);
return this;
}

/**
* Get the container property: The code interpreter container. Can be a container ID or an object that
* specifies uploaded file IDs to make available to your code, along with an
* optional `memory_limit` setting.
* If not provided, the service assumes auto.
*
* @return the container value as a String.
*/
public String getContainerAsString() {
// AI Tooling: union type
if (this.container == null) {
return null;
}
return this.container.toObject(String.class);
}

/**
* Get the container property: The code interpreter container. Can be a container ID or an object that
* specifies uploaded file IDs to make available to your code, along with an
* optional `memory_limit` setting.
* If not provided, the service assumes auto.
*
* @return the container value as an {@link AutoCodeInterpreterToolParam}.
*/
public AutoCodeInterpreterToolParam getContainerAsAutoCodeInterpreterToolParam() {
// AI Tooling: union type
if (this.container == null) {
return null;
}
return this.container.toObject(AutoCodeInterpreterToolParam.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,28 +100,6 @@ public FileSearchTool setRankingOptions(RankingOptions rankingOptions) {
return this;
}

/**
* Get the filters property: The filters property.
*
* @return the filters value.
*/
@Generated
public BinaryData getFilters() {
return this.filters;
}

/**
* Set the filters property: The filters property.
*
* @param filters the filters value to set.
* @return the FileSearchTool object itself.
*/
@Generated
public FileSearchTool setFilters(BinaryData filters) {
this.filters = filters;
return this;
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -214,6 +192,28 @@ public FileSearchTool setMaxResults(Long maxResults) {
return this;
}

/**
* Get the filters property: The filters property.
*
* @return the filters value.
*/
BinaryData getFilters() {
// AI Tooling: union type
return this.filters;
}

/**
* Set the filters property: The filters property.
*
* @param filters the filters value to set.
* @return the FileSearchTool object itself.
*/
FileSearchTool setFilters(BinaryData filters) {
// AI Tooling: union type
this.filters = filters;
return this;
}

/**
* Sets the file search filters using an openai-java {@link ComparisonFilter}.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
Expand Down Expand Up @@ -270,8 +271,8 @@ public McpTool setHeaders(Map<String, String> headers) {
*
* @return the allowedTools value.
*/
@Generated
public BinaryData getAllowedTools() {
BinaryData getAllowedTools() {
// AI Tooling: union type
return this.allowedTools;
}

Expand All @@ -281,19 +282,70 @@ public BinaryData getAllowedTools() {
* @param allowedTools the allowedTools value to set.
* @return the McpTool object itself.
*/
@Generated
public McpTool setAllowedTools(BinaryData allowedTools) {
McpTool setAllowedTools(BinaryData allowedTools) {
// AI Tooling: union type
this.allowedTools = allowedTools;
return this;
}

/**
* Set the allowedTools property: The allowed_tools property.
*
* @param allowedTools the list of tool name strings to set.
* @return the McpTool object itself.
*/
public McpTool setAllowedTools(List<String> allowedTools) {
// AI Tooling: union type
this.allowedTools = BinaryData.fromObject(allowedTools);
return this;
}

/**
* Set the allowedTools property: The allowed_tools property.
*
* @param allowedTools the {@link McpToolFilter} to set.
* @return the McpTool object itself.
*/
public McpTool setAllowedTools(McpToolFilter allowedTools) {
// AI Tooling: union type
this.allowedTools = BinaryData.fromObject(allowedTools);
return this;
}

/**
* Get the allowedTools property: The allowed_tools property.
*
* @return the allowedTools value as a list of Strings.
*/
@SuppressWarnings("unchecked")
public List<String> getAllowedToolsAsStringList() {
// AI Tooling: union type
if (this.allowedTools == null) {
return null;
}
return this.allowedTools.toObject(List.class);
}

/**
* Get the allowedTools property: The allowed_tools property.
*
* @return the allowedTools value as a {@link McpToolFilter}.
*/
public McpToolFilter getAllowedToolsAsMcpToolFilter() {
// AI Tooling: union type
if (this.allowedTools == null) {
return null;
}
return this.allowedTools.toObject(McpToolFilter.class);
}

/**
* Get the requireApproval property: The require_approval property.
*
* @return the requireApproval value.
*/
@Generated
public BinaryData getRequireApproval() {
BinaryData getRequireApproval() {
// AI Tooling: union type
return this.requireApproval;
}

Expand All @@ -303,12 +355,62 @@ public BinaryData getRequireApproval() {
* @param requireApproval the requireApproval value to set.
* @return the McpTool object itself.
*/
@Generated
public McpTool setRequireApproval(BinaryData requireApproval) {
McpTool setRequireApproval(BinaryData requireApproval) {
// AI Tooling: union type
this.requireApproval = requireApproval;
return this;
}

/**
* Set the requireApproval property: The require_approval property.
*
* @param requireApproval the approval setting string to set (e.g., "always" or "never").
* @return the McpTool object itself.
*/
public McpTool setRequireApproval(String requireApproval) {
// AI Tooling: union type
this.requireApproval = BinaryData.fromString(requireApproval);
return this;
}

/**
* Set the requireApproval property: The require_approval property.
*
* @param requireApproval the {@link McpToolRequireApproval} filter to set.
* @return the McpTool object itself.
*/
public McpTool setRequireApproval(McpToolRequireApproval requireApproval) {
// AI Tooling: union type
this.requireApproval = BinaryData.fromObject(requireApproval);
return this;
}

/**
* Get the requireApproval property: The require_approval property.
*
* @return the requireApproval value as a String.
*/
public String getRequireApprovalAsString() {
// AI Tooling: union type
if (this.requireApproval == null) {
return null;
}
return this.requireApproval.toObject(String.class);
}

/**
* Get the requireApproval property: The require_approval property.
*
* @return the requireApproval value as a {@link McpToolRequireApproval}.
*/
public McpToolRequireApproval getRequireApprovalAsMcpToolRequireApproval() {
// AI Tooling: union type
if (this.requireApproval == null) {
return null;
}
return this.requireApproval.toObject(McpToolRequireApproval.class);
}
Comment thread
jpalvarezl marked this conversation as resolved.

/**
* Get the projectConnectionId property: The connection ID in the project for the MCP server. The connection stores
* authentication and other connection details needed to connect to the MCP server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.azure.ai.agents.models.AgentVersionDetails;
import com.azure.ai.agents.models.McpTool;
import com.azure.ai.agents.models.PromptAgentDefinition;
import com.azure.core.util.BinaryData;
import com.azure.core.util.Configuration;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.openai.models.responses.ResponseCreateParams;
Expand Down Expand Up @@ -51,7 +50,7 @@ public static void main(String[] args) {
McpTool customCodeInterpreter = new McpTool("custom-code-interpreter")
.setServerUrl(mcpServerUrl)
.setProjectConnectionId(connectionId)
.setRequireApproval(BinaryData.fromObject("never"));
.setRequireApproval("never");

PromptAgentDefinition agentDefinition = new PromptAgentDefinition(model)
.setInstructions("You are a helpful assistant that can run Python code to analyze data and solve problems.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.azure.ai.agents.models.AgentVersionDetails;
import com.azure.ai.agents.models.McpTool;
import com.azure.ai.agents.models.PromptAgentDefinition;
import com.azure.core.util.BinaryData;
import com.azure.core.util.Configuration;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.openai.models.responses.Response;
Expand Down Expand Up @@ -49,7 +48,7 @@ public static void main(String[] args) {
McpTool customCodeInterpreter = new McpTool("custom-code-interpreter")
.setServerUrl(mcpServerUrl)
.setProjectConnectionId(connectionId)
.setRequireApproval(BinaryData.fromObject("never"));
.setRequireApproval("never");

PromptAgentDefinition agentDefinition = new PromptAgentDefinition(model)
.setInstructions("You are a helpful assistant that can run Python code to analyze data and solve problems.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.azure.ai.agents.models.AgentVersionDetails;
import com.azure.ai.agents.models.McpTool;
import com.azure.ai.agents.models.PromptAgentDefinition;
import com.azure.core.util.BinaryData;
import com.azure.core.util.Configuration;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.openai.models.responses.ResponseCreateParams;
Expand Down Expand Up @@ -56,7 +55,7 @@ public static void main(String[] args) {
// Uses gitmcp.io to expose a GitHub repository as an MCP-compatible server
McpTool tool = new McpTool("api-specs")
.setServerUrl("https://gitmcp.io/Azure/azure-rest-api-specs")
.setRequireApproval(BinaryData.fromObject("always"));
.setRequireApproval("always");

PromptAgentDefinition agentDefinition = new PromptAgentDefinition(model)
.setInstructions("You are a helpful agent that can use MCP tools to assist users. "
Expand Down
Loading