Skip to content

fix(tool): return suspended results for external tools#1668

Open
jsiu93 wants to merge 5 commits into
agentscope-ai:mainfrom
jsiu93:fix/1582-external-tool-suspended
Open

fix(tool): return suspended results for external tools#1668
jsiu93 wants to merge 5 commits into
agentscope-ai:mainfrom
jsiu93:fix/1582-external-tool-suspended

Conversation

@jsiu93

@jsiu93 jsiu93 commented Jun 7, 2026

Copy link
Copy Markdown

AgentScope-Java Version

2.0.0-SNAPSHOT

Description

Fixes #1582.

External tools were short-circuited with Mono.error(new ToolSuspendException()) before the executor's ToolSuspendException conversion path, so batch execution could convert external tool calls into generic error results.

This PR:

  • Returns ToolResultBlock.suspended(toolCall) directly for external tools in ToolExecutor
  • Emits RequireExternalExecutionEvent when the agent event stream sees suspended tool calls
  • Updates external-tool Javadocs to describe the direct suspended-result flow
  • Adds executor and ReActAgent regressions for TOOL_SUSPENDED, RUNNING state, and external execution events

How to test:

  • mvn -pl agentscope-core -Dtest=ToolExecutorTest,ReActAgentNewLoopReplyTest test
  • mvn -pl agentscope-core -Dtest=ReActAgentHitlTest,ExternalToolSupportTest,AgentEventStreamTest,GenerateReasonTest test
  • mvn -pl agentscope-core test

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 (external-tool Javadocs)
  • Code is ready for review

@jsiu93 jsiu93 requested a review from a team June 7, 2026 08:18
@CLAassistant

CLAassistant commented Jun 7, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codecov

codecov Bot commented Jun 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@AgentScopeJavaBot AgentScopeJavaBot added bug Something isn't working area/core/tool Tool, skill, RAG abstractions labels Jun 7, 2026

@AgentScopeJavaBot AgentScopeJavaBot 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.

🤖 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.)

jsiu93 added 4 commits June 9, 2026 10:48
# Conflicts:
#	agentscope-core/src/main/java/io/agentscope/core/ReActAgent.java
# Conflicts:
#	agentscope-core/src/main/java/io/agentscope/core/ReActAgent.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core/tool Tool, skill, RAG abstractions bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: External tools return generic execution errors instead of suspended results

3 participants