Skip to content

Conversation

@shlokmestry
Copy link
Contributor

AgentScope-Java Version

1.0.4-SNAPSHOT

Description

This PR adds a Kotlin coroutine extension layer for AgentScope Java to improve the Kotlin developer experience while keeping Reactor as the core async implementation.

A new optional module agentscope-kotlin is introduced under agentscope-extensions, providing Kotlin-friendly APIs on top of existing Reactor-based methods:

  • Mono<Msg>suspend fun
  • Flux<Event>Flow<Event>
  • Mono<Void>suspend fun returning Unit

All extensions are implemented as Kotlin extension functions, so no existing Java APIs or behaviors are changed.

What’s Included

  • New agentscope-kotlin extension module
  • Coroutine wrappers for Agent.call(...), Agent.observe(...), and Agent.stream(...)
  • Uses kotlinx-coroutines-reactor for non-blocking interoperability
  • No changes to core modules or Java implementations

Example Usage

val response = agent.callSuspend(msg)

agent.streamFlow(msg).collect { event ->
    println(event)
}

##How to test:

mvn -pl agentscope-extensions/agentscope-kotlin -am test

@shlokmestry shlokmestry requested a review from a team December 26, 2025 18:17
@shlokmestry
Copy link
Contributor Author

The remaining failure appears to be in agentscope-extensions-a2a-client, which is unrelated to this PR.

Comment on lines 95 to 97
// Cached sorted hooks (invalidated when hooks list changes)
private transient volatile List<Hook> cachedSortedHooks;
private final AtomicBoolean hooksDirty = new AtomicBoolean(true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert these changes

Comment on lines 37 to 38
<kotlin.version>1.9.24</kotlin.version>
<kotlin.coroutines.version>1.8.1</kotlin.coroutines.version>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version should be managed in agentscope-dependencies-bom

<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>agentscope-kotlin</artifactId>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<artifactId>agentscope-kotlin</artifactId>
<artifactId>agentscope-extensions-kotlin</artifactId>

@codecov
Copy link

codecov bot commented Jan 1, 2026

Codecov Report

❌ Patch coverage is 56.25000% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...e/src/main/java/io/agentscope/core/ReActAgent.java 56.25% 7 Missing ⚠️

📢 Thoughts on this report? Let us know!

@shlokmestry
Copy link
Contributor Author

All checks are now passing and the license headers have been aligned with the repo standard.
Ready for review/merge. Thanks!

@Akika404
Copy link
Contributor

Akika404 commented Jan 8, 2026

Hi, thank you for your contributions to the Kotlin community. However, using Kotlin 1.9.24 feels a bit outdated at this point. The mainstream version in the community has already moved to Kotlin 2.x, which provides better support for the K2 Compiler. To avoid potential technical debt in the future, would it make sense to consider migrating directly to Kotlin 2.x?

@shlokmestry
Copy link
Contributor Author

Hi, that’s a very valid point.
For this PR, I intentionally aligned with the repository’s current Kotlin version to keep the change focused and minimize risk. Since this contribution introduces a new coroutine extension layer without altering existing core behavior, I wanted to avoid coupling it with a major language upgrade in the same PR.
I agree that moving to Kotlin 2.x (and K2) is an important consideration and would likely be beneficial long-term. However, given the scope and potential impact of such a migration, it may be better handled as a separate, dedicated effort so it can be evaluated, tested, and reviewed independently.
I’m happy to help with or contribute to a Kotlin 2.x migration in a follow-up PR if that’s something the maintainers would like to pursue.

@AlbumenJ
Copy link
Collaborator

image Please fix conficts :)

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.

3 participants