Commit 719f910
Responses protocol methods (#49244)
* 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>
* Add protocol-method tests for ResponsesClient and ResponsesAsyncClient
Mirrors the existing basicCRUDOperations tests against the new createResponseWithResponse protocol methods (BinaryData + RequestOptions), parses the returned HttpResponseFor<Response>, and asserts on the same shape (non-null Response with an id) as the typed-method tests. Tests remain @disabled pending public preview recordings, consistent with the existing typed tests.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Enable Responses tests with full create/retrieve/delete/cancel/input-items coverage
Cleanup, expansion, and enablement of ResponsesTests and ResponsesAsyncTests:
1. Removed the stale '// currently returning 500' comments and the orphan getOpenAIClient() pseudo-code blocks from the initial Agents V2 commit (PR #47134). Live calls against the service confirmed all four previously-flagged endpoints (retrieve, delete, cancel, input_items) now return 200.
2. Expanded both typed and protocol-method tests to actually exercise the full surface: create -> retrieve -> input_items -> delete in basicCRUDOperations, plus a separate cancelBackgroundResponse / cancelBackgroundResponseWithResponse that creates a background:true response and cancels it (asserting CANCELLED or COMPLETED, since the response may finish before cancel hits). 4 test methods per class (sync + async) x 2 surfaces = 8 tests total.
3. Dropped the class-level @disabled annotations now that recordings exist. Captured live recordings via AZURE_TEST_MODE=RECORD against the Foundry endpoint, pushed via 'test-proxy push -a assets.json' to Azure/azure-sdk-assets, and bumped the assets.json Tag to java/ai/azure-ai-agents_7a1b5ec037. Verified by re-running in default (playback) mode: all 8 tests pass.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Narrow Responses protocol-methods scope to create + createStream only
Drop the getResponseWithResponse, deleteResponseWithResponse, and
cancelResponseWithResponse protocol methods added previously. The
ResponsesClient/ResponsesAsyncClient surface now exposes protocol-method
variants only for createAzureResponse and createStreamingAzureResponse,
matching the original typed surface.
Tests:
- Trim basicCRUDOperationsWithResponse to exercise createResponseWithResponse only.
- Add basicStreamingOperationsWithResponse to cover createResponseStreamWithResponse.
- Drop cancelBackgroundResponseWithResponse.
- Re-recorded affected sessions; bumped assets.json tag.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Use OpenAI client directly for response get/delete/cancel in tests
ResponsesClient and ResponsesAsyncClient are thin Azure-aware wrappers,
so non-Azure operations (retrieve, delete, cancel) should go through the
underlying com.openai client directly rather than the wrappers' service
getters. Adds getResponseServiceSyncClient/getResponseServiceAsyncClient
helpers in ClientTestBase that build the OpenAIClient/OpenAIClientAsync
and expose .responses(). Updates basicCRUDOperations and
cancelBackgroundResponse in both test classes to use the new helpers
for retrieve/delete/cancel; create still flows through ResponsesClient.
Recordings unchanged (the OpenAI client built by AgentsClientBuilder
shares the same Azure HTTP pipeline as the wrappers' service).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address PR review feedback on Responses protocol methods
- Reword JavaDoc on createResponseWithResponse in both clients to
clarify the JSON body is forwarded semantically (parsed and
re-serialized via additionalBodyProperties), not byte-for-byte, since
property ordering may change and duplicate top-level keys are not
preserved.
- Apply the same clarification to the streaming variant JavaDoc.
- Wrap HttpResponseFor<Response> in try-with-resources in
basicCRUDOperationsWithResponse for both sync and async test classes
so the response is reliably closed.
- Remove unused CREATE_BACKGROUND_RESPONSE_BODY constant in both test
classes.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent ae12cde commit 719f910
8 files changed
Lines changed: 379 additions & 51 deletions
File tree
- sdk/ai/azure-ai-agents
- src
- main/java/com/azure/ai/agents
- implementation
- test/java/com/azure/ai/agents
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
7 | 13 | | |
8 | 14 | | |
9 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
Lines changed: 74 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
| |||
84 | 88 | | |
85 | 89 | | |
86 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
87 | 161 | | |
Lines changed: 72 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
| |||
97 | 101 | | |
98 | 102 | | |
99 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
100 | 172 | | |
Lines changed: 32 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
| 163 | + | |
170 | 164 | | |
171 | 165 | | |
172 | 166 | | |
173 | 167 | | |
174 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
175 | 200 | | |
176 | 201 | | |
177 | 202 | | |
| |||
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
87 | 99 | | |
88 | 100 | | |
89 | 101 | | |
| |||
0 commit comments