[Feature]: Add Kotlin coroutine extension layer (suspend / Flow APIs)
Background
agentscope-java exposes many async APIs based on Reactor (Mono / Flux).
This works well for Java, but is not idiomatic for Kotlin, where suspend functions and Flow
Proposal
Add a Kotlin coroutine extension module, e.g.:
agentscope-kotlin
This module would not change the core implementation, but provide Kotlin-friendly APIs on top of the existing Reactor-based core.
Goal
At the API level, convert:
Mono
Flux
So Kotlin users rarely need to interact with Reactor types directly.
Example
suspend fun Agent.send(request: Request): Response
fun Agent.streamEvents(): Flow
Internally backed by Mono.awaitSingle() and Flux.asFlow().
Summary
Keep Reactor as the core async implementation
Add a Kotlin coroutine extension layer
Improve Kotlin developer experience without impacting Java users
Contribution Welcome!
I'd like to take this one. @AlbumenJ
Note that agentscope-extensions-kotlin existed on the 1.x branch but was not carried over to 2.0 — the BOM still manages kotlin.version / kotlin.coroutines.version, so the module is simply missing. This would restore it, rebuilt against the 2.0 API rather than a straight port.
Plan:
-
New module
agentscope-extensions/agentscope-extensions-kotlin, registered inagentscope-allandagentscope-bomsoCheck Module Syncstays green. -
Extensions over the non-deprecated 2.0 surface only:
CallableAgent.call(...)(Mono) →callSuspend(...)suspend overloadsObservableAgent.observe(...)(Mono) → observeSuspend(...)ReActAgent.streamEvents(...)/HarnessAgent.streamEvents(...)(Flux) → streamEventsFlow(...): Flow
I plan to skip
StreamableAgent.stream(...), since all of its overloads are@Deprecated(since = "2.0.0", forRemoval = true)in favour ofstreamEvents. Wrapping them would ship a new module built on an API that is scheduled for removal. Happy to include them (deprecated as well) if you'd prefer parity with 1.x. -
Naming keeps the 1.x convention (
callSuspend/observeSuspend) so 1.x users migrate cleanly. Extension functions cannot reuse the member names — Kotlin resolves member functions before extensions, soagent.call(msg)would always bind to the Mono-returning member. -
agentscope-harnesswill be anoptionaldependency so the HarnessAgent extensions are available when harness is on the classpath, without forcing it on core-only users. -
Unit tests covering value/exception propagation, empty-Mono behaviour, Flow ordering and completion, and cancellation propagating back to the Reactor subscription.
Will keep the change scoped to the new module plus the two distribution registrations.