Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import com.azure.ai.agents.implementation.models.CreateAgentRequest;
import com.azure.ai.agents.implementation.models.CreateAgentVersionFromManifestRequest;
import com.azure.ai.agents.implementation.models.CreateAgentVersionRequest;
import com.azure.ai.agents.implementation.models.DeleteAgentResponse;
import com.azure.ai.agents.implementation.models.UpdateAgentFromManifestRequest;
import com.azure.ai.agents.implementation.models.UpdateAgentRequest;
import com.azure.ai.agents.models.AgentDefinition;
import com.azure.ai.agents.models.AgentDefinitionOptInKeys;
import com.azure.ai.agents.models.AgentDetails;
import com.azure.ai.agents.models.AgentKind;
import com.azure.ai.agents.models.AgentVersionDetails;
import com.azure.ai.agents.models.DeleteAgentResponse;
import com.azure.ai.agents.models.DeleteAgentVersionResponse;
import com.azure.ai.agents.models.PageOrder;
import com.azure.core.annotation.Generated;
Expand Down Expand Up @@ -95,34 +95,6 @@ public Mono<Response<BinaryData>> getAgentWithResponse(String agentName, Request
return this.serviceClient.getAgentWithResponseAsync(agentName, requestOptions);
}

/**
* Deletes an agent.
* <p><strong>Response Body Schema</strong></p>
*
* <pre>
* {@code
* {
* object: String(agent/agent.version/agent.deleted/agent.version.deleted/agent.container) (Required)
* name: String (Required)
* deleted: boolean (Required)
* }
* }
* </pre>
*
* @param agentName The name of the agent to delete.
* @param requestOptions The options to configure the HTTP request before HTTP client sends it.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @return a deleted agent Object along with {@link Response} on successful completion of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<BinaryData>> deleteAgentWithResponse(String agentName, RequestOptions requestOptions) {
return this.serviceClient.deleteAgentWithResponseAsync(agentName, requestOptions);
}

/**
* Create a new agent version.
* <p><strong>Header Parameters</strong></p>
Expand Down Expand Up @@ -309,27 +281,6 @@ public Mono<AgentDetails> getAgent(String agentName) {
.map(protocolMethodData -> protocolMethodData.toObject(AgentDetails.class));
}

/**
* Deletes an agent.
*
* @param agentName The name of the agent to delete.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a deleted agent Object on successful completion of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<DeleteAgentResponse> deleteAgent(String agentName) {
// Generated convenience method for deleteAgentWithResponse
RequestOptions requestOptions = new RequestOptions();
return deleteAgentWithResponse(agentName, requestOptions).flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(DeleteAgentResponse.class));
}

/**
* Returns the list of all agents.
*
Expand Down Expand Up @@ -1432,4 +1383,69 @@ public Mono<AgentVersionDetails> createAgentVersion(String agentName, AgentDefin
.flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(AgentVersionDetails.class));
}

/**
* Deletes an agent.
* <p><strong>Response Body Schema</strong></p>
*
* <pre>
* {@code
* {
* object: String(agent/agent.version/agent.deleted/agent.version.deleted/agent.container) (Required)
* name: String (Required)
* deleted: boolean (Required)
* }
* }
* </pre>
*
* @param agentName The name of the agent to delete.
* @param requestOptions The options to configure the HTTP request before HTTP client sends it.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @return a deleted agent Object along with {@link Response} on successful completion of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
Mono<Response<BinaryData>> internalDeleteAgentWithResponse(String agentName, RequestOptions requestOptions) {
return this.serviceClient.internalDeleteAgentWithResponseAsync(agentName, requestOptions);
}

/**
* Deletes an agent.
*
* @param agentName The name of the agent to delete.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a deleted agent Object on successful completion of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
Mono<DeleteAgentResponse> internalDeleteAgent(String agentName) {
// Generated convenience method for internalDeleteAgentWithResponse
RequestOptions requestOptions = new RequestOptions();
return internalDeleteAgentWithResponse(agentName, requestOptions).flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(DeleteAgentResponse.class));
}

/**
* Deletes an agent.
*
* @param agentName The name of the agent to delete.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Void> deleteAgent(String agentName) {
return internalDeleteAgent(agentName).then();
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

AgentsAsyncClient.deleteAgent delegates to internalDeleteAgent(agentName).then(), which still deserializes the delete response into DeleteAgentResponse even though the public API returns Mono<Void>. To reduce overhead and avoid coupling to the response body, consider delegating to internalDeleteAgentWithResponse(agentName, requestOptions).then() (or otherwise avoiding the toObject(DeleteAgentResponse.class) step).

Suggested change
return internalDeleteAgent(agentName).then();
RequestOptions requestOptions = new RequestOptions();
return internalDeleteAgentWithResponse(agentName, requestOptions).then();

Copilot uses AI. Check for mistakes.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import com.azure.ai.agents.implementation.models.CreateAgentRequest;
import com.azure.ai.agents.implementation.models.CreateAgentVersionFromManifestRequest;
import com.azure.ai.agents.implementation.models.CreateAgentVersionRequest;
import com.azure.ai.agents.implementation.models.DeleteAgentResponse;
import com.azure.ai.agents.implementation.models.UpdateAgentFromManifestRequest;
import com.azure.ai.agents.implementation.models.UpdateAgentRequest;
import com.azure.ai.agents.models.AgentDefinition;
import com.azure.ai.agents.models.AgentDefinitionOptInKeys;
import com.azure.ai.agents.models.AgentDetails;
import com.azure.ai.agents.models.AgentKind;
import com.azure.ai.agents.models.AgentVersionDetails;
import com.azure.ai.agents.models.DeleteAgentResponse;
import com.azure.ai.agents.models.DeleteAgentVersionResponse;
import com.azure.ai.agents.models.PageOrder;
import com.azure.core.annotation.Generated;
Expand Down Expand Up @@ -89,34 +89,6 @@ public Response<BinaryData> getAgentWithResponse(String agentName, RequestOption
return this.serviceClient.getAgentWithResponse(agentName, requestOptions);
}

/**
* Deletes an agent.
* <p><strong>Response Body Schema</strong></p>
*
* <pre>
* {@code
* {
* object: String(agent/agent.version/agent.deleted/agent.version.deleted/agent.container) (Required)
* name: String (Required)
* deleted: boolean (Required)
* }
* }
* </pre>
*
* @param agentName The name of the agent to delete.
* @param requestOptions The options to configure the HTTP request before HTTP client sends it.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @return a deleted agent Object along with {@link Response}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<BinaryData> deleteAgentWithResponse(String agentName, RequestOptions requestOptions) {
return this.serviceClient.deleteAgentWithResponse(agentName, requestOptions);
}

/**
* Create a new agent version.
* <p><strong>Header Parameters</strong></p>
Expand Down Expand Up @@ -301,26 +273,6 @@ public AgentDetails getAgent(String agentName) {
return getAgentWithResponse(agentName, requestOptions).getValue().toObject(AgentDetails.class);
}

/**
* Deletes an agent.
*
* @param agentName The name of the agent to delete.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a deleted agent Object.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public DeleteAgentResponse deleteAgent(String agentName) {
// Generated convenience method for deleteAgentWithResponse
RequestOptions requestOptions = new RequestOptions();
return deleteAgentWithResponse(agentName, requestOptions).getValue().toObject(DeleteAgentResponse.class);
}

/**
* Returns the list of all agents.
*
Expand Down Expand Up @@ -1364,4 +1316,69 @@ public AgentVersionDetails createAgentVersion(String agentName, AgentDefinition
return createAgentVersionWithResponse(agentName, createAgentVersionRequest, requestOptions).getValue()
.toObject(AgentVersionDetails.class);
}

/**
* Deletes an agent.
*
* @param agentName The name of the agent to delete.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public void deleteAgent(String agentName) {
internalDeleteAgent(agentName);
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

deleteAgent currently calls internalDeleteAgent(agentName) and discards the returned DeleteAgentResponse, which still forces a JSON-to-object deserialization. Since the public method is intentionally void, consider delegating to internalDeleteAgentWithResponse(...) (or the underlying impl method that returns Response<BinaryData>) and ignoring the body to avoid unnecessary deserialization work and avoid coupling the public method to the response schema.

Suggested change
internalDeleteAgent(agentName);
RequestOptions requestOptions = new RequestOptions();
internalDeleteAgentWithResponse(agentName, requestOptions);

Copilot uses AI. Check for mistakes.
}
Comment on lines +1331 to +1334
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

This API change (making AgentsClient.deleteAgent return void and removing DeleteAgentResponse from the public models package) breaks in-repo usages that still expect DeleteAgentResponse (for example the DeleteAgent sample and AgentsTests). Those call sites need to be updated to call deleteAgent(...) without capturing a return value (and to stop importing com.azure.ai.agents.models.DeleteAgentResponse).

Copilot uses AI. Check for mistakes.

/**
* Deletes an agent.
* <p><strong>Response Body Schema</strong></p>
*
* <pre>
* {@code
* {
* object: String(agent/agent.version/agent.deleted/agent.version.deleted/agent.container) (Required)
* name: String (Required)
* deleted: boolean (Required)
* }
* }
* </pre>
*
* @param agentName The name of the agent to delete.
* @param requestOptions The options to configure the HTTP request before HTTP client sends it.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @return a deleted agent Object along with {@link Response}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
Response<BinaryData> internalDeleteAgentWithResponse(String agentName, RequestOptions requestOptions) {
return this.serviceClient.internalDeleteAgentWithResponse(agentName, requestOptions);
}

/**
* Deletes an agent.
*
* @param agentName The name of the agent to delete.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a deleted agent Object.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
DeleteAgentResponse internalDeleteAgent(String agentName) {
// Generated convenience method for internalDeleteAgentWithResponse
RequestOptions requestOptions = new RequestOptions();
return internalDeleteAgentWithResponse(agentName, requestOptions).getValue()
.toObject(DeleteAgentResponse.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Response<BinaryData> updateAgentFromManifestSync(@HostParam("endpoint") String e
@UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
@UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
@UnexpectedResponseExceptionType(HttpResponseException.class)
Mono<Response<BinaryData>> deleteAgent(@HostParam("endpoint") String endpoint,
Mono<Response<BinaryData>> internalDeleteAgent(@HostParam("endpoint") String endpoint,
@PathParam("agent_name") String agentName, @QueryParam("api-version") String apiVersion,
@HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context);

Expand All @@ -208,7 +208,7 @@ Mono<Response<BinaryData>> deleteAgent(@HostParam("endpoint") String endpoint,
@UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 })
@UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 })
@UnexpectedResponseExceptionType(HttpResponseException.class)
Response<BinaryData> deleteAgentSync(@HostParam("endpoint") String endpoint,
Response<BinaryData> internalDeleteAgentSync(@HostParam("endpoint") String endpoint,
@PathParam("agent_name") String agentName, @QueryParam("api-version") String apiVersion,
@HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context);

Expand Down Expand Up @@ -1062,9 +1062,10 @@ public Response<BinaryData> updateAgentFromManifestWithResponse(String agentName
* @return a deleted agent Object along with {@link Response} on successful completion of {@link Mono}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<BinaryData>> deleteAgentWithResponseAsync(String agentName, RequestOptions requestOptions) {
public Mono<Response<BinaryData>> internalDeleteAgentWithResponseAsync(String agentName,
RequestOptions requestOptions) {
final String accept = "application/json";
return FluxUtil.withContext(context -> service.deleteAgent(this.client.getEndpoint(), agentName,
return FluxUtil.withContext(context -> service.internalDeleteAgent(this.client.getEndpoint(), agentName,
this.client.getServiceVersion().getVersion(), accept, requestOptions, context));
}

Expand All @@ -1091,9 +1092,9 @@ public Mono<Response<BinaryData>> deleteAgentWithResponseAsync(String agentName,
* @return a deleted agent Object along with {@link Response}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<BinaryData> deleteAgentWithResponse(String agentName, RequestOptions requestOptions) {
public Response<BinaryData> internalDeleteAgentWithResponse(String agentName, RequestOptions requestOptions) {
final String accept = "application/json";
return service.deleteAgentSync(this.client.getEndpoint(), agentName,
return service.internalDeleteAgentSync(this.client.getEndpoint(), agentName,
this.client.getServiceVersion().getVersion(), accept, requestOptions, Context.NONE);
}

Expand Down
Loading
Loading