fix(tool): return suspended results for external tools#1668
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
This is a clean, well-targeted fix for issue #1582. The core change — replacing Mono.error(new ToolSuspendException()) with Mono.just(ToolResultBlock.suspended(toolCall)) — eliminates exception-driven control flow for external tools, making the batch execution path more predictable and robust. The addition of RequireExternalExecutionEvent provides a proper event-stream signal for external orchestrators. Test coverage is solid at both unit (ToolExecutorTest) and integration (ReActAgentNewLoopReplyTest) levels. One minor behavior change worth noting: external tools now bypass the group activation check (see inline comment).
(inline comments could not be attached — line numbers fell outside PR hunks. See archived report.)
# Conflicts: # agentscope-core/src/main/java/io/agentscope/core/ReActAgent.java
# Conflicts: # agentscope-core/src/main/java/io/agentscope/core/ReActAgent.java
AgentScope-Java Version
2.0.0-SNAPSHOT
Description
Fixes #1582.
External tools were short-circuited with
Mono.error(new ToolSuspendException())before the executor'sToolSuspendExceptionconversion path, so batch execution could convert external tool calls into generic error results.This PR:
ToolResultBlock.suspended(toolCall)directly for external tools inToolExecutorRequireExternalExecutionEventwhen the agent event stream sees suspended tool callsTOOL_SUSPENDED,RUNNINGstate, and external execution eventsHow to test:
mvn -pl agentscope-core -Dtest=ToolExecutorTest,ReActAgentNewLoopReplyTest testmvn -pl agentscope-core -Dtest=ReActAgentHitlTest,ExternalToolSupportTest,AgentEventStreamTest,GenerateReasonTest testmvn -pl agentscope-core testChecklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)