From e3874b61a8918183a1421d5396819976fb0132af Mon Sep 17 00:00:00 2001
From: Jose Alvarez
Date: Fri, 22 May 2026 11:42:37 +0200
Subject: [PATCH 1/6] Add protocol methods to ResponsesClient and
ResponsesAsyncClient
Adds BinaryData + com.openai.core.RequestOptions protocol-style methods on the Responses sync and async clients that delegate to the openai-java ResponseService.withRawResponse() / ResponseServiceAsync.withRawResponse() surface and return the openai-java raw HTTP response types directly. Specifically:
- createResponseWithResponse / createResponseStreamWithResponse
- getResponseWithResponse
- deleteResponseWithResponse
- cancelResponseWithResponse
The async variants wrap the underlying CompletableFuture in Mono.fromFuture(...). All methods continue to flow through the Azure HTTP pipeline via HttpClientHelper.mapToOpenAIHttpClient. Adds OpenAIJsonHelper.jsonBodyToValueMap(BinaryData) helper used by the create methods to forward the raw JSON body verbatim through ResponseCreateParams.Builder.additionalBodyProperties.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
sdk/ai/azure-ai-agents/CHANGELOG.md | 2 +
.../azure/ai/agents/ResponsesAsyncClient.java | 130 ++++++++++++++++++
.../com/azure/ai/agents/ResponsesClient.java | 127 +++++++++++++++++
.../implementation/OpenAIJsonHelper.java | 39 +++++-
4 files changed, 291 insertions(+), 7 deletions(-)
diff --git a/sdk/ai/azure-ai-agents/CHANGELOG.md b/sdk/ai/azure-ai-agents/CHANGELOG.md
index 6a3c9a299b51..eea929205c6a 100644
--- a/sdk/ai/azure-ai-agents/CHANGELOG.md
+++ b/sdk/ai/azure-ai-agents/CHANGELOG.md
@@ -4,6 +4,8 @@
### Features Added
+- Added protocol-style methods on `ResponsesClient` and `ResponsesAsyncClient` that accept a raw JSON request body (`BinaryData`) and a `com.openai.core.RequestOptions`, and return the openai-java raw HTTP response (`HttpResponseFor`, `HttpResponseFor>`, and `HttpResponse`). New methods: `createResponseWithResponse`, `createResponseStreamWithResponse`, `getResponseWithResponse`, `deleteResponseWithResponse`, and `cancelResponseWithResponse`. These delegate to the underlying openai-java `ResponseService.withRawResponse()` surface and continue to flow through the Azure HTTP pipeline.
+
### Breaking Changes
### Bugs Fixed
diff --git a/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/ResponsesAsyncClient.java b/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/ResponsesAsyncClient.java
index 3ebcace05ea9..a783c71712c6 100644
--- a/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/ResponsesAsyncClient.java
+++ b/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/ResponsesAsyncClient.java
@@ -10,8 +10,13 @@
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
import com.azure.core.annotation.ServiceMethod;
+import com.azure.core.util.BinaryData;
import com.openai.client.OpenAIClientAsync;
import com.openai.core.JsonValue;
+import com.openai.core.RequestOptions;
+import com.openai.core.http.HttpResponse;
+import com.openai.core.http.HttpResponseFor;
+import com.openai.core.http.StreamResponse;
import com.openai.models.responses.Response;
import com.openai.models.responses.ResponseCreateParams;
import com.openai.models.responses.ResponseStreamEvent;
@@ -84,4 +89,129 @@ public Flux createStreamingAzureResponse(AzureCreateRespons
params.additionalBodyProperties(additionalBodyProperties);
return StreamingUtils.toFlux(this.responseServiceAsync.createStreaming(params.build()));
}
+
+ /**
+ * Creates a response from a raw JSON request body and returns the raw HTTP response.
+ *
+ * This protocol method delegates to the OpenAI Java SDK's
+ * {@link ResponseServiceAsync.WithRawResponse#create(ResponseCreateParams, RequestOptions)}. The
+ * {@code createResponseRequest} payload is forwarded verbatim as the request body, so callers can
+ * include Azure-specific extensions (such as
+ * {@link com.azure.ai.agents.models.AgentReference}) without going through the strongly-typed
+ * {@link ResponseCreateParams.Builder}.
+ *
+ * The returned {@link HttpResponseFor} exposes the status code, headers, and the raw
+ * response stream via {@code body()}, or the typed {@link Response} via {@code parse()}. Only
+ * one of {@code body()} or {@code parse()} may be invoked per response, and the caller must
+ * close the response (e.g. via try-with-resources) to release the underlying connection.
+ *
+ * Note: the second parameter is the openai-java {@link RequestOptions} (not the azure-core
+ * type) so that the OpenAI-supported options (timeout, response validation) translate
+ * faithfully. Additional headers or query parameters must be supplied via the OpenAI request
+ * builder pattern (e.g. by using {@link #createAzureResponse} for fully-typed requests).
+ *
+ * @param createResponseRequest the JSON body representing the create-response request; must be a JSON object.
+ * @param requestOptions optional OpenAI request options; pass {@code null} to use the defaults.
+ * @return a {@link Mono} emitting the raw HTTP response, parseable as a {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> createResponseWithResponse(BinaryData createResponseRequest,
+ RequestOptions requestOptions) {
+ Objects.requireNonNull(createResponseRequest, "createResponseRequest cannot be null");
+
+ ResponseCreateParams params = ResponseCreateParams.builder()
+ .additionalBodyProperties(OpenAIJsonHelper.jsonBodyToValueMap(createResponseRequest))
+ .build();
+ return Mono.fromFuture(this.responseServiceAsync.withRawResponse()
+ .create(params, requestOptions == null ? RequestOptions.none() : requestOptions));
+ }
+
+ /**
+ * Creates a streaming response from a raw JSON request body and returns the raw HTTP response.
+ *
+ * Delegates to the OpenAI Java SDK's
+ * {@link ResponseServiceAsync.WithRawResponse#createStreaming(ResponseCreateParams, RequestOptions)}.
+ * The {@code createResponseRequest} payload is forwarded verbatim as the request body.
+ *
+ * The returned {@link HttpResponseFor} wraps a {@link StreamResponse} of
+ * {@link ResponseStreamEvent} items, which the caller iterates via {@link HttpResponseFor#parse()}.
+ * Note that the underlying stream produced by the openai-java SDK's raw async streaming API is
+ * iterator-based and blocking; for a Reactor-friendly streaming surface use
+ * {@link #createStreamingAzureResponse(AzureCreateResponseOptions, ResponseCreateParams.Builder)}
+ * instead.
+ *
+ * @param createResponseRequest the JSON body representing the create-response request; must be a JSON object.
+ * @param requestOptions optional OpenAI request options; pass {@code null} to use the defaults.
+ * @return a {@link Mono} emitting the raw HTTP response, parseable as a {@link StreamResponse} of {@link ResponseStreamEvent}.
+ */
+ @ServiceMethod(returns = ReturnType.COLLECTION)
+ public Mono>>
+ createResponseStreamWithResponse(BinaryData createResponseRequest, RequestOptions requestOptions) {
+ Objects.requireNonNull(createResponseRequest, "createResponseRequest cannot be null");
+
+ ResponseCreateParams params = ResponseCreateParams.builder()
+ .additionalBodyProperties(OpenAIJsonHelper.jsonBodyToValueMap(createResponseRequest))
+ .build();
+ return Mono.fromFuture(this.responseServiceAsync.withRawResponse()
+ .createStreaming(params, requestOptions == null ? RequestOptions.none() : requestOptions));
+ }
+
+ /**
+ * Retrieves a previously created response by id and returns the raw HTTP response.
+ *
+ * Delegates to the OpenAI Java SDK's
+ * {@link ResponseServiceAsync.WithRawResponse#retrieve(String, RequestOptions)}.
+ *
+ * @param responseId the id of the response to retrieve.
+ * @param requestOptions optional OpenAI request options; pass {@code null} to use the defaults.
+ * @return a {@link Mono} emitting the raw HTTP response, parseable as a {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> getResponseWithResponse(String responseId, RequestOptions requestOptions) {
+ Objects.requireNonNull(responseId, "responseId cannot be null");
+
+ return Mono.fromFuture(this.responseServiceAsync.withRawResponse()
+ .retrieve(responseId, requestOptions == null ? RequestOptions.none() : requestOptions));
+ }
+
+ /**
+ * Deletes a previously created response and returns the raw HTTP response.
+ *
+ * Delegates to the OpenAI Java SDK's
+ * {@link ResponseServiceAsync.WithRawResponse#delete(String, RequestOptions)}.
+ *
+ * The returned {@link HttpResponse} exposes the status code and headers; the body (if any)
+ * can be read via {@link HttpResponse#body()}. Callers must close the response to release the
+ * underlying connection.
+ *
+ * @param responseId the id of the response to delete.
+ * @param requestOptions optional OpenAI request options; pass {@code null} to use the defaults.
+ * @return a {@link Mono} emitting the raw HTTP response.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono deleteResponseWithResponse(String responseId, RequestOptions requestOptions) {
+ Objects.requireNonNull(responseId, "responseId cannot be null");
+
+ return Mono.fromFuture(this.responseServiceAsync.withRawResponse()
+ .delete(responseId, requestOptions == null ? RequestOptions.none() : requestOptions));
+ }
+
+ /**
+ * Cancels a previously created response and returns the raw HTTP response.
+ *
+ * Delegates to the OpenAI Java SDK's
+ * {@link ResponseServiceAsync.WithRawResponse#cancel(String, RequestOptions)}.
+ *
+ * @param responseId the id of the response to cancel.
+ * @param requestOptions optional OpenAI request options; pass {@code null} to use the defaults.
+ * @return a {@link Mono} emitting the raw HTTP response, parseable as a {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> cancelResponseWithResponse(String responseId,
+ RequestOptions requestOptions) {
+ Objects.requireNonNull(responseId, "responseId cannot be null");
+
+ return Mono.fromFuture(this.responseServiceAsync.withRawResponse()
+ .cancel(responseId, requestOptions == null ? RequestOptions.none() : requestOptions));
+ }
}
diff --git a/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/ResponsesClient.java b/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/ResponsesClient.java
index 687bf8c5316c..96b695109d3e 100644
--- a/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/ResponsesClient.java
+++ b/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/ResponsesClient.java
@@ -11,9 +11,14 @@
import com.azure.core.annotation.ServiceClient;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.ReturnType;
+import com.azure.core.util.BinaryData;
import com.azure.core.util.IterableStream;
import com.openai.client.OpenAIClient;
import com.openai.core.JsonValue;
+import com.openai.core.RequestOptions;
+import com.openai.core.http.HttpResponse;
+import com.openai.core.http.HttpResponseFor;
+import com.openai.core.http.StreamResponse;
import com.openai.models.responses.Response;
import com.openai.models.responses.ResponseCreateParams;
import com.openai.models.responses.ResponseStreamEvent;
@@ -97,4 +102,126 @@ public static AzureCreateResponseDetails getAzureFields(Response response) {
AzureCreateResponseDetails::fromJson);
}
+ /**
+ * Creates a response from a raw JSON request body and returns the raw HTTP response.
+ *
+ * This protocol method delegates to the OpenAI Java SDK's
+ * {@link ResponseService.WithRawResponse#create(ResponseCreateParams, RequestOptions)}. The
+ * {@code createResponseRequest} payload is forwarded verbatim as the request body, so callers can
+ * include Azure-specific extensions (such as
+ * {@link com.azure.ai.agents.models.AgentReference}) without going through the strongly-typed
+ * {@link ResponseCreateParams.Builder}.
+ *
+ * The returned {@link HttpResponseFor} exposes the status code, headers, and the raw
+ * response stream via {@code body()}, or the typed {@link Response} via {@code parse()}. Only
+ * one of {@code body()} or {@code parse()} may be invoked per response, and the caller must
+ * close the response (e.g. via try-with-resources) to release the underlying connection.
+ *
+ * Note: the second parameter is the openai-java {@link RequestOptions} (not the azure-core
+ * type) so that the OpenAI-supported options (timeout, response validation) translate
+ * faithfully. Additional headers or query parameters must be supplied via the OpenAI request
+ * builder pattern (e.g. by using {@link #createAzureResponse} for fully-typed requests).
+ *
+ * @param createResponseRequest the JSON body representing the create-response request; must be a JSON object.
+ * @param requestOptions optional OpenAI request options; pass {@code null} to use the defaults.
+ * @return the raw HTTP response, parseable as a {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public HttpResponseFor createResponseWithResponse(BinaryData createResponseRequest,
+ RequestOptions requestOptions) {
+ Objects.requireNonNull(createResponseRequest, "createResponseRequest cannot be null");
+
+ ResponseCreateParams params = ResponseCreateParams.builder()
+ .additionalBodyProperties(OpenAIJsonHelper.jsonBodyToValueMap(createResponseRequest))
+ .build();
+ return this.responseService.withRawResponse()
+ .create(params, requestOptions == null ? RequestOptions.none() : requestOptions);
+ }
+
+ /**
+ * Creates a streaming response from a raw JSON request body and returns the raw HTTP response.
+ *
+ * Delegates to the OpenAI Java SDK's
+ * {@link ResponseService.WithRawResponse#createStreaming(ResponseCreateParams, RequestOptions)}.
+ * The {@code createResponseRequest} payload is forwarded verbatim as the request body.
+ *
+ * The returned {@link HttpResponseFor} wraps a {@link StreamResponse} of
+ * {@link ResponseStreamEvent} items, which the caller iterates via {@link HttpResponseFor#parse()}.
+ * The underlying stream must be closed when iteration completes; the typical pattern is
+ * try-with-resources on either the {@link HttpResponseFor} or the parsed {@link StreamResponse}.
+ *
+ * @param createResponseRequest the JSON body representing the create-response request; must be a JSON object.
+ * @param requestOptions optional OpenAI request options; pass {@code null} to use the defaults.
+ * @return the raw HTTP response, parseable as a {@link StreamResponse} of {@link ResponseStreamEvent}.
+ */
+ @ServiceMethod(returns = ReturnType.COLLECTION)
+ public HttpResponseFor>
+ createResponseStreamWithResponse(BinaryData createResponseRequest, RequestOptions requestOptions) {
+ Objects.requireNonNull(createResponseRequest, "createResponseRequest cannot be null");
+
+ ResponseCreateParams params = ResponseCreateParams.builder()
+ .additionalBodyProperties(OpenAIJsonHelper.jsonBodyToValueMap(createResponseRequest))
+ .build();
+ return this.responseService.withRawResponse()
+ .createStreaming(params, requestOptions == null ? RequestOptions.none() : requestOptions);
+ }
+
+ /**
+ * Retrieves a previously created response by id and returns the raw HTTP response.
+ *
+ * Delegates to the OpenAI Java SDK's
+ * {@link ResponseService.WithRawResponse#retrieve(String, RequestOptions)}.
+ *
+ * @param responseId the id of the response to retrieve.
+ * @param requestOptions optional OpenAI request options; pass {@code null} to use the defaults.
+ * @return the raw HTTP response, parseable as a {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public HttpResponseFor getResponseWithResponse(String responseId, RequestOptions requestOptions) {
+ Objects.requireNonNull(responseId, "responseId cannot be null");
+
+ return this.responseService.withRawResponse()
+ .retrieve(responseId, requestOptions == null ? RequestOptions.none() : requestOptions);
+ }
+
+ /**
+ * Deletes a previously created response and returns the raw HTTP response.
+ *
+ * Delegates to the OpenAI Java SDK's
+ * {@link ResponseService.WithRawResponse#delete(String, RequestOptions)}.
+ *
+ * The returned {@link HttpResponse} exposes the status code and headers; the body (if any)
+ * can be read via {@link HttpResponse#body()}. Callers must close the response to release the
+ * underlying connection.
+ *
+ * @param responseId the id of the response to delete.
+ * @param requestOptions optional OpenAI request options; pass {@code null} to use the defaults.
+ * @return the raw HTTP response.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public HttpResponse deleteResponseWithResponse(String responseId, RequestOptions requestOptions) {
+ Objects.requireNonNull(responseId, "responseId cannot be null");
+
+ return this.responseService.withRawResponse()
+ .delete(responseId, requestOptions == null ? RequestOptions.none() : requestOptions);
+ }
+
+ /**
+ * Cancels a previously created response and returns the raw HTTP response.
+ *
+ * Delegates to the OpenAI Java SDK's
+ * {@link ResponseService.WithRawResponse#cancel(String, RequestOptions)}.
+ *
+ * @param responseId the id of the response to cancel.
+ * @param requestOptions optional OpenAI request options; pass {@code null} to use the defaults.
+ * @return the raw HTTP response, parseable as a {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public HttpResponseFor cancelResponseWithResponse(String responseId, RequestOptions requestOptions) {
+ Objects.requireNonNull(responseId, "responseId cannot be null");
+
+ return this.responseService.withRawResponse()
+ .cancel(responseId, requestOptions == null ? RequestOptions.none() : requestOptions);
+ }
+
}
diff --git a/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/implementation/OpenAIJsonHelper.java b/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/implementation/OpenAIJsonHelper.java
index d5fdcab14f1f..c7d15a77fcf2 100644
--- a/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/implementation/OpenAIJsonHelper.java
+++ b/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/implementation/OpenAIJsonHelper.java
@@ -160,18 +160,43 @@ public static > Map toJsonValue
}
try {
String json = BinaryData.fromObject(obj).toString();
- Map map = MAPPER.readValue(json, new TypeReference
*
* The returned {@link HttpResponseFor} wraps a {@link StreamResponse} of
* {@link ResponseStreamEvent} items, which the caller iterates via {@link HttpResponseFor#parse()}.
diff --git a/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/ResponsesClient.java b/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/ResponsesClient.java
index 7352c73ae68d..f179f0192fe2 100644
--- a/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/ResponsesClient.java
+++ b/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/ResponsesClient.java
@@ -106,8 +106,10 @@ public static AzureCreateResponseDetails getAzureFields(Response response) {
*
*
This protocol method delegates to the OpenAI Java SDK's
* {@link ResponseService.WithRawResponse#create(ResponseCreateParams, RequestOptions)}. The
- * {@code createResponseRequest} payload is forwarded verbatim as the request body, so callers can
- * include Azure-specific extensions (such as
+ * {@code createResponseRequest} payload is forwarded as the request body (semantically, not
+ * byte-for-byte: the JSON is parsed and re-serialized via {@code additionalBodyProperties},
+ * so property ordering and exact formatting may change and duplicate top-level keys are not
+ * preserved), so callers can include Azure-specific extensions (such as
* {@link com.azure.ai.agents.models.AgentReference}) without going through the strongly-typed
* {@link ResponseCreateParams.Builder}.
*
@@ -142,7 +144,9 @@ public HttpResponseFor createResponseWithResponse(BinaryData createRes
*
* Delegates to the OpenAI Java SDK's
* {@link ResponseService.WithRawResponse#createStreaming(ResponseCreateParams, RequestOptions)}.
- * The {@code createResponseRequest} payload is forwarded verbatim as the request body.
+ * The {@code createResponseRequest} payload is forwarded as the request body (semantically,
+ * not byte-for-byte: the JSON is parsed and re-serialized, so property ordering and exact
+ * formatting may change and duplicate top-level keys are not preserved).
*
* The returned {@link HttpResponseFor} wraps a {@link StreamResponse} of
* {@link ResponseStreamEvent} items, which the caller iterates via {@link HttpResponseFor#parse()}.
diff --git a/sdk/ai/azure-ai-agents/src/test/java/com/azure/ai/agents/ResponsesAsyncTests.java b/sdk/ai/azure-ai-agents/src/test/java/com/azure/ai/agents/ResponsesAsyncTests.java
index 76f0414436cd..e9e7d064f368 100644
--- a/sdk/ai/azure-ai-agents/src/test/java/com/azure/ai/agents/ResponsesAsyncTests.java
+++ b/sdk/ai/azure-ai-agents/src/test/java/com/azure/ai/agents/ResponsesAsyncTests.java
@@ -32,10 +32,6 @@ public class ResponsesAsyncTests extends ClientTestBase {
private static final String CREATE_STREAM_RESPONSE_BODY
= "{\"input\":\"Hello, how can you help me?\",\"model\":\"gpt-4o\",\"stream\":true}";
- private static final String CREATE_BACKGROUND_RESPONSE_BODY
- = "{\"input\":\"Tell me a very long story about a chicken trying to cross the road.\","
- + "\"model\":\"gpt-4o\",\"background\":true}";
-
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.ai.agents.TestUtils#getTestParameters")
public void basicCRUDOperations(HttpClient httpClient, AgentsServiceVersion serviceVersion)
@@ -96,12 +92,13 @@ public void cancelBackgroundResponse(HttpClient httpClient, AgentsServiceVersion
public void basicCRUDOperationsWithResponse(HttpClient httpClient, AgentsServiceVersion serviceVersion) {
ResponsesAsyncClient client = getResponsesAsyncClient(httpClient, serviceVersion);
- HttpResponseFor createdRaw
- = client.createResponseWithResponse(BinaryData.fromString(CREATE_RESPONSE_BODY), null).block();
- assertNotNull(createdRaw);
- Response createdResponse = createdRaw.parse();
- assertNotNull(createdResponse);
- assertNotNull(createdResponse.id());
+ try (HttpResponseFor createdRaw
+ = client.createResponseWithResponse(BinaryData.fromString(CREATE_RESPONSE_BODY), null).block()) {
+ assertNotNull(createdRaw);
+ Response createdResponse = createdRaw.parse();
+ assertNotNull(createdResponse);
+ assertNotNull(createdResponse.id());
+ }
}
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
diff --git a/sdk/ai/azure-ai-agents/src/test/java/com/azure/ai/agents/ResponsesTests.java b/sdk/ai/azure-ai-agents/src/test/java/com/azure/ai/agents/ResponsesTests.java
index 1d7b4078fd16..5eb0c3d6b1da 100644
--- a/sdk/ai/azure-ai-agents/src/test/java/com/azure/ai/agents/ResponsesTests.java
+++ b/sdk/ai/azure-ai-agents/src/test/java/com/azure/ai/agents/ResponsesTests.java
@@ -30,10 +30,6 @@ public class ResponsesTests extends ClientTestBase {
private static final String CREATE_STREAM_RESPONSE_BODY
= "{\"input\":\"Hello, how can you help me?\",\"model\":\"gpt-4o\",\"stream\":true}";
- private static final String CREATE_BACKGROUND_RESPONSE_BODY
- = "{\"input\":\"Tell me a very long story about a chicken trying to cross the road.\","
- + "\"model\":\"gpt-4o\",\"background\":true}";
-
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
@MethodSource("com.azure.ai.agents.TestUtils#getTestParameters")
public void basicCRUDOperations(HttpClient httpClient, AgentsServiceVersion serviceVersion) {
@@ -92,12 +88,13 @@ public void cancelBackgroundResponse(HttpClient httpClient, AgentsServiceVersion
public void basicCRUDOperationsWithResponse(HttpClient httpClient, AgentsServiceVersion serviceVersion) {
ResponsesClient client = getResponsesSyncClient(httpClient, serviceVersion);
- HttpResponseFor createdRaw
- = client.createResponseWithResponse(BinaryData.fromString(CREATE_RESPONSE_BODY), null);
- assertNotNull(createdRaw);
- Response createdResponse = createdRaw.parse();
- assertNotNull(createdResponse);
- assertNotNull(createdResponse.id());
+ try (HttpResponseFor createdRaw
+ = client.createResponseWithResponse(BinaryData.fromString(CREATE_RESPONSE_BODY), null)) {
+ assertNotNull(createdRaw);
+ Response createdResponse = createdRaw.parse();
+ assertNotNull(createdResponse);
+ assertNotNull(createdResponse.id());
+ }
}
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)