Skip to content

refactor(agent): convert ReActAgent to synchronous execution and add tool streaming support - #14

Merged
chickenlj merged 1 commit into
agentscope-ai:mainfrom
AlbumenJ:1021-tool-stream
Oct 22, 2025
Merged

chickenlj merged 1 commit into
agentscope-ai:mainfrom
AlbumenJ:1021-tool-stream

Conversation

@AlbumenJ

@AlbumenJ AlbumenJ commented Oct 21, 2025 •

Copy link
Copy Markdown
Collaborator

Simplify ReActAgent implementation by removing complex reactive composition chains
and using straightforward synchronous code. The doCall() layer remains the only
sync-to-async conversion point using Mono.fromCallable().

Additionally, introduce ToolEmitter interface to enable tools to send streaming
progress updates during execution.

ReActAgent Synchronization:

  • executeReActLoop(): Convert from recursive Mono to simple for loop
  • reasoning(): Use Flux.toIterable() for real-time chunk streaming to hooks
    instead of collectList().block() which batches all chunks
  • acting(): Execute tools synchronously with .block() on results
  • Message ordering: Only save text messages when no tool calls exist,
    preventing DashScope API validation errors

Tool Streaming (ToolEmitter):

  • Add ToolEmitter interface for streaming tool execution progress
  • Auto-inject ToolEmitter parameters in tool methods
  • Add Hook.onToolChunk() to receive streaming chunks
  • Streaming chunks are for monitoring only, NOT sent to LLM
  • Support concurrent tool execution with independent emitters per tool
  • Refactor ToolResponse → ToolResultConverter for cleaner API

…cution with real-time streaming

  Simplify ReActAgent implementation by removing complex reactive composition chains
  and using straightforward synchronous code. The doCall() layer remains the only
  sync-to-async conversion point using Mono.fromCallable().

  Key changes:
  - executeReActLoop(): Convert from recursive Mono to simple for loop
  - reasoning(): Use Flux.toIterable() for real-time chunk streaming to hooks
    instead of collectList().block() which batches all chunks
  - acting(): Execute tools synchronously with .block() on results
  - Message ordering: Only save text messages when no tool calls exist,
    preventing DashScope API validation errors

Change-Id: I482dc2b7a94c0034d9b63ef0f48432fef13183c5
@AlbumenJ AlbumenJ changed the title refactor(agent): convert ReActAgent async assembly to synchronous execution with real-time streaming refactor(agent): convert ReActAgent to synchronous execution and add tool streaming support Oct 21, 2025

@chickenlj chickenlj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM.

@chickenlj
chickenlj merged commit 26208f6 into agentscope-ai:main Oct 22, 2025
JGoP-L pushed a commit to JGoP-L/agentscope-java that referenced this pull request Dec 29, 2025
LiangshouX added a commit to LiangshouX/agentscope-java that referenced this pull request Sep 8, 2026
- agentscope-ai#1: Fix search() to use prefix matching (gte/lt range query) with \u001F separator

- agentscope-ai#2: Make parseValue() fail-fast on JSON decode errors and unexpected types

- agentscope-ai#3: Add validateKey/namespacePath validation; change separator from \0 to \u001F

- agentscope-ai#4: Use compound Document _id {user, session} instead of ":" delimited string

- agentscope-ai#5: Move state keys into states sub-document to avoid reserved field collisions

- agentscope-ai#6: Delete contradictory test; introduce Testcontainers 1.21.4 for CI contract tests

- agentscope-ai#7: Use aggregate + \$size for O(1) list count instead of full array transfer

- agentscope-ai#8: Use 2-thread pool for renewal; guard implements AutoCloseable with cascading close

- agentscope-ai#9: Extract MongoIndexUtils.createIndexWithMigration using listIndexes() for actual names

- agentscope-ai#10: Read database name from connection string in fromConnectionString and Builder

- agentscope-ai#11: Use UUID token for lock renew/release instead of non-unique owner (pid)

- agentscope-ai#12: Use convertValue instead of JSON string round-trip for serialization

- agentscope-ai#13: Centralize default names in MongoConstants

- agentscope-ai#14: Add EN/ZH MongoDB integration docs and update capability matrices

- agentscope-ai#15: Use full SHA-256 digest for lock IDs (no truncation)

- agentscope-ai#16: Apply error-85 migration to all indexes via unified createIndexWithMigration

Additional fixes:

- Atomic findOneAndUpdate for saveIfVersion UNVERSIONED path

- Move FIELD_KEY/FIELD_NAMESPACE to setOnInsert in put()

- Rename validateKey to validateStateKey in MongoAgentStateStore

Tests: 124 passing (104 unit + 20 contract), 0 failures, 0 errors
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.

2 participants