fix(stream): use subscribeOn instead of publishOn for blocking stream sources#410
Merged
AlbumenJ merged 3 commits intoagentscope-ai:mainfrom Dec 31, 2025
Merged
fix(stream): use subscribeOn instead of publishOn for blocking stream sources#410AlbumenJ merged 3 commits intoagentscope-ai:mainfrom
AlbumenJ merged 3 commits intoagentscope-ai:mainfrom
Conversation
… sources Change-Id: I447edd7c8e4efff4efa6fabc4bb89eb6583fc80a
… sources Change-Id: Ia64cb92acf4330b46084657d34080eae144ed2c5
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes threading issues in streaming operations by replacing publishOn with subscribeOn when working with blocking stream sources. The change ensures that blocking I/O operations and synchronous data source iteration happen on appropriate thread pools rather than blocking reactive pipelines.
- Corrects scheduler usage for Flux sources that perform blocking operations (HTTP streaming, Java Stream/Iterable conversion)
- Applies the fix across multiple model implementations and HTTP transport layers
- Updates 6 files with consistent scheduler pattern changes
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| agentscope-core/src/main/java/io/agentscope/core/model/transport/OkHttpTransport.java | Changes streaming HTTP SSE handling to use subscribeOn for blocking BufferedReader operations |
| agentscope-examples/model-request-compression/src/main/java/io/agentscope/examples/compression/extra/CompressingOkHttpTransport.java | Same streaming fix for compressed HTTP transport variant |
| agentscope-core/src/main/java/io/agentscope/core/model/OpenAIChatModel.java | Fixes scheduler for Flux.fromStream() conversion from OpenAI SDK's blocking Stream |
| agentscope-core/src/main/java/io/agentscope/core/model/GeminiChatModel.java | Fixes scheduler for Flux.fromIterable() conversion from Gemini's ResponseStream |
| agentscope-core/src/main/java/io/agentscope/core/model/AnthropicChatModel.java | Fixes scheduler for Flux.fromStream() conversion from Anthropic SDK's blocking Stream |
| agentscope-core/src/main/java/io/agentscope/core/agent/AgentBase.java | Changes event stream creation scheduler, though this source is reactive rather than blocking |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
agentscope-core/src/main/java/io/agentscope/core/agent/AgentBase.java
Outdated
Show resolved
Hide resolved
…se.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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.
No description provided.