Skip to content

feat(tool): preserve Event block types in SubAgentTool forwardEvent#1282

Open
jujn wants to merge 2 commits into
agentscope-ai:mainfrom
jujn:feat_980
Open

feat(tool): preserve Event block types in SubAgentTool forwardEvent#1282
jujn wants to merge 2 commits into
agentscope-ai:mainfrom
jujn:feat_980

Conversation

@jujn

@jujn jujn commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Description

Close #980
Enhance SubAgentTool forwardEvent to preserve original ContentBlock types and provide empty block fallback.

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 (e.g. links, examples, etc.)
  • Code is ready for review

@jujn jujn requested review from a team and Copilot April 25, 2026 07:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates SubAgentTool.forwardEvent to forward sub-agent streaming events without losing the original ContentBlock subtypes (e.g., ToolUseBlock), addressing the type-erasure problem described in #980. It also adds a fallback behavior to emit an empty block when an event has no content.

Changes:

  • Updated SubAgentTool.forwardEvent to emit the original Msg content blocks (instead of JSON text) and attach event metadata (subagent_event_type, subagent_event_last, etc.).
  • Added an empty TextBlock fallback when an event has no content blocks to forward.
  • Updated SubAgentToolTest to assert preserved ContentBlock types and correct metadata population.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
agentscope-core/src/main/java/io/agentscope/core/tool/subagent/SubAgentTool.java Emit original event content blocks and attach event metadata; add empty-block fallback.
agentscope-core/src/test/java/io/agentscope/core/tool/subagent/SubAgentToolTest.java Update streaming-forwarding test to validate block-type preservation and metadata.

@codecov

codecov Bot commented Apr 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.33333% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...io/agentscope/core/tool/subagent/SubAgentTool.java 58.33% 1 Missing and 4 partials ⚠️

📢 Thoughts on this report? Let us know!

@LearningGp

Copy link
Copy Markdown
Member
image

@AgentScopeJavaBot AgentScopeJavaBot added enhancement New feature or request area/core/tool Tool, skill, RAG abstractions labels May 28, 2026
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 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: SubAgentTool.forwardEvent 方法实现疑问

4 participants