Skip to content

fix(anthropic): migrate AnthropicChatModel to ModelSchedulers (#4437) - #4439

Open
Acerola-1 wants to merge 1 commit into
agentscope-ai:mainfrom
Acerola-1:fix/anthropic-model-schedulers
Open

Acerola-1 wants to merge 1 commit into
agentscope-ai:mainfrom
Acerola-1:fix/anthropic-model-schedulers

Conversation

@Acerola-1

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.1.0-SNAPSHOT (targeting main)

Description

Fixes #4437

Companion fix to the 2.0.x ModelSchedulers backport (#4436 / #4438) to ensure full scheduling parity across all model extensions on main and prevent regression when upgrading from 2.0.6 to 2.1.0.

Changes

  • agentscope-extensions-model-anthropic:
    • Migrated AnthropicChatModel.doStream(...) outer responseFlux from Schedulers.boundedElastic() to streamEnabled ? ModelSchedulers.streams() : ModelSchedulers.requests() before ModelUtils.applyTimeoutAndRetry(...) so both synchronous client.messages().createStreaming(params) connection setup and non-streaming kickoff run on ModelSchedulers.
    • Removed the redundant inner .subscribeOn(Schedulers.boundedElastic()) on Flux.fromStream(streamResponse.stream()) to avoid unnecessary thread switches.
    • Added AnthropicChatModelSchedulingTest verifying with MockWebServer (including delayed SSE headers) and a tracking formatter that streaming connect/iteration run on agentscope-model-stream-* without blocking caller subscribe(), and non-streaming kickoff runs on agentscope-model-request-*.

Verification

  • git grep -n "boundedElastic" under agentscope-extensions/agentscope-extensions-model/agentscope-extensions-model-anthropic/src/main: empty (0 remaining calls).
  • Ran mvn -T1C -pl agentscope-extensions/agentscope-extensions-model/agentscope-extensions-model-anthropic -am spotless:apply spotless:check test (BUILD SUCCESS):
    • agentscope-core: 3,567 run, 0 failed, 0 errors, 11 pre-existing skipped
    • agentscope-extensions-model-anthropic: 262 run, 0 failed, 0 errors, 0 skipped (AnthropicChatModelSchedulingTest: 2/2)
  • Documentation: ModelSchedulers is already documented on main (docs/dev/{en,zh}/docs/building-blocks/model.md), so no doc changes are needed here.

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: AnthropicChatModel still uses Reactor's global Schedulers.boundedElastic() on main

1 participant