Fix streaming APIs in Agents and Projects libraries#48832
Merged
srnagar merged 6 commits intoAzure:mainfrom Apr 16, 2026
Merged
Fix streaming APIs in Agents and Projects libraries#48832srnagar merged 6 commits intoAzure:mainfrom
srnagar merged 6 commits intoAzure:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to enable true streaming HTTP response bodies (Flux<ByteBuffer> → InputStream) in the azure-ai-agents and azure-ai-projects libraries while improving request execution threading behavior to avoid completing futures on I/O event loop threads.
Changes:
- Added a
FluxInputStreamimplementation (in both Agents and Projects) plus corresponding tests. - Updated OpenAI HTTP response adapters to return a streaming
InputStreambacked by the underlying Azure response bodyFlux. - Updated OpenAI HTTP client helper to avoid eager response reading and to complete requests on
Schedulers.boundedElastic().
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 18 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/core/azure-core/src/main/java/com/azure/core/http/HttpResponse.java | Adds a new getBodyStream() convenience API intended to expose streaming bodies as InputStream. |
| sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/http/FluxInputStream.java | New Flux→InputStream bridge used by Projects response adapter. |
| sdk/ai/azure-ai-projects/src/test/java/com/azure/ai/projects/implementation/http/FluxInputStreamTests.java | Tests for Projects FluxInputStream. |
| sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/http/AzureHttpResponseAdapter.java | Switches Projects adapter body() to streaming via Flux-backed InputStream. |
| sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/http/HttpClientHelper.java | Ensures completion/continuations don’t run on I/O threads; stops eager response reading. |
| sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/implementation/http/FluxInputStream.java | New Flux→InputStream bridge used by Agents response adapter. |
| sdk/ai/azure-ai-agents/src/test/java/com/azure/ai/agents/implementation/http/FluxInputStreamTests.java | Tests for Agents FluxInputStream. |
| sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/implementation/http/AzureHttpResponseAdapter.java | Switches Agents adapter body() to streaming via Flux-backed InputStream. |
| sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/implementation/http/HttpClientHelper.java | Ensures completion/continuations don’t run on I/O threads; stops eager response reading. |
kaylieee
approved these changes
Apr 16, 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 a new utility class,
FluxInputStream, to bridge between Reactor'sFlux<ByteBuffer>and Java'sInputStream, and refactors HTTP response handling to use this class. This enables non-blocking, streaming response bodies while maintaining compatibility with existing interfaces. Additionally, the request context and threading behavior for HTTP calls are improved. Comprehensive tests forFluxInputStreamare also added.Core HTTP streaming improvements:
FluxInputStreamclass, which allows reading from aFlux<ByteBuffer>as anInputStream, handling synchronization, backpressure, and error propagation.AzureHttpResponseAdapter.body()in bothazure-ai-agentsandazure-ai-projectsto useFluxInputStreaminstead of the previous.getBodyAsBinaryData().toStream(), preparing for future API changes and enabling true streaming. [1] [2]Testing:
FluxInputStreamTests, a comprehensive test suite covering normal operation, empty buffers, and error propagation for the new stream class.Threading and context improvements:
.publishOn(Schedulers.boundedElastic()), preventing blocking of event loop threads. [1] [2]HttpClientHelperto no longer eagerly read responses, improving streaming and resource usage.Code cleanup:
AzureHttpResponseAdapter.These changes collectively improve the efficiency, reliability, and test coverage of HTTP streaming in the SDK.
NOTE:
FluxInputStreamwill be moved toazure-coreand HttpResponse will be updated to provide API to get theInputStreamdirectly. Agents and Projects will be updated to remove duplication when new version ofazure-coreis available.