Repository navigation
Conversation
5 tasks done
This branch has not been deployed
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.
AgentScope-Java Version
2.0.6-SNAPSHOT (targeting
2.0.x)Description
Fixes #4436
Minimal, forward-compatible backport of
ModelSchedulersand caller-owned transportstreamSchedulerfrommain(PR #4154, commita4306d63d) to2.0.x. Companionmainparity forAnthropicChatModelis tracked in #4437.On
2.0.x, model calls, HTTP transport SSE reads, andAgentBase.createEventStream()hardcoded Reactor's globalSchedulers.boundedElastic(), which defaults to10 * availableProcessors(20threads on 2 vCPU containers) and shares threads with application, tool, MCP, RAG, and state-store workloads. Under high concurrency (e.g., 60–240 concurrent non-streaming model calls), requests queue behind the shared 20-thread pool before outbound dispatch and exhaust timeout budgets.Changes
agentscope-core:io.agentscope.core.model.ModelSchedulersverbatim frommain(requests(),streams(),responses()), raising the default thread cap tomax(64, 10 * availableProcessors)with per-thread queue capacity256and exposing positive JVM properties:agentscope.model.requestThreadCap,agentscope.model.streamThreadCap,agentscope.model.responseThreadCap, andagentscope.model.taskQueueCapacity.Builder.streamScheduler(Scheduler)overrides (defaulting toModelSchedulers.streams(), never disposed bytransport.close()) toJdkHttpTransportandOkHttpTransport, replacing allSchedulers.boundedElastic()usages while keeping2.0.xstreaming state machines (sendInputStreamAsync,Flux.create) and existing constructors unchanged.AgentBase.createEventStream().publishOn(Schedulers.boundedElastic())to.publishOn(ModelSchedulers.responses()).agentscope-extensions-model-*(all 6 model providers):OpenAIChatModel,DashScopeChatModel,OllamaChatModel: migrated blocking execution/request prep toModelSchedulers.requests().OpenAIResponsesChatModel: non-streaming →ModelSchedulers.requests(), streaming →ModelSchedulers.streams().GeminiChatModel: removed redundant inner.subscribeOn(...)and migrated outer.subscribeOn(...)tostreamEnabled ? ModelSchedulers.streams() : ModelSchedulers.requests().AnthropicChatModel: removed redundant inner.subscribeOn(...)and migrated outerresponseFluxtostreamEnabled ? ModelSchedulers.streams() : ModelSchedulers.requests()beforeModelUtils.applyTimeoutAndRetry(...)so bothcreateStreaming()connection setup and stream iteration run off caller threads.docs/v2/en/docs/building-blocks/model.mdanddocs/v2/zh/docs/building-blocks/model.mdwithModelSchedulersJVM properties andJdkHttpTransport/OkHttpTransportBuilder.streamScheduler(...)usage accurate to2.0.x.ModelSchedulersTest(13 cases): role prefixes,-XX:ActiveProcessorCount=2default 64 cap across all 3 pools, child-JVM isolation with saturatedboundedElasticSize=1,0/-1validation across all 4 properties,taskQueueCapacity=1rejection, andAgentBase.stream(...)cancellation + temporaryStreamingHookcleanup.HttpTransportStreamSchedulerTest(5 cases):nullrejection, custom stream thread verification, HTTP 500 error propagation, stalled/slow SSE cancellation, and non-disposal checks for bothJdkHttpTransportandOkHttpTransport.OpenAIChatModelSchedulingTest(1 case) andAnthropicChatModelSchedulingTest(2 cases).Verification
git grep -n "boundedElastic"acrossagentscope-core/src/main/java/io/agentscope/core/model,AgentBase.java, andagentscope-extensions/agentscope-extensions-model: empty (0 remaining calls).mvn -T1C -pl agentscope-core,agentscope-extensions/agentscope-extensions-model/agentscope-extensions-model-openai,agentscope-extensions/agentscope-extensions-model/agentscope-extensions-model-dashscope,agentscope-extensions/agentscope-extensions-model/agentscope-extensions-model-ollama,agentscope-extensions/agentscope-extensions-model/agentscope-extensions-model-gemini,agentscope-extensions/agentscope-extensions-model/agentscope-extensions-model-anthropic,agentscope-extensions/agentscope-extensions-model/agentscope-extensions-model-openai-official -am spotless:apply spotless:check test(BUILD SUCCESS):agentscope-core: 3,260 run, 0 failed, 0 errors, 11 pre-existing skipped (ModelSchedulersTest: 13/13,HttpTransportStreamSchedulerTest: 5/5)agentscope-extensions-model-openai: 573 run, 0 failed, 0 errors, 11 pre-existing skipped (OpenAIChatModelSchedulingTest: 1/1)agentscope-extensions-model-dashscope: 482 run, 0 failed, 0 errors, 2 pre-existing skippedagentscope-extensions-model-openai-official: 291 run, 0 failed, 0 errors, 2 pre-existing skippedagentscope-extensions-model-anthropic: 206 run, 0 failed, 0 errors, 0 skipped (AnthropicChatModelSchedulingTest: 2/2)agentscope-extensions-model-ollama: 193 run, 0 failed, 0 errors, 1 pre-existing skippedagentscope-extensions-model-gemini: 156 run, 0 failed, 0 errors, 0 skippeddocs/scripts/check-docs.mjs(inspectPage&checkSite) passed on both editeddocs/v2/{en,zh}/docs/building-blocks/model.md; fulldocsnpm suite (website.yml) and full reactormvn -B -T1C clean verifyare deferred to PR CI (the isolated worktree has nodocs/node_modules).Checklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)