Skip to content

feat(core): wrap ContentBlock tool returns instead of JSON-serializing - #4299

Merged
jujn merged 7 commits into
agentscope-ai:mainfrom
xzxiaoshan:feat/tool-contentblock-returns
Nov 21, 2026
Merged

jujn merged 7 commits into
agentscope-ai:mainfrom
xzxiaoshan:feat/tool-contentblock-returns

Conversation

@xzxiaoshan

Copy link
Copy Markdown
Collaborator

AgentScope-Java Version

2.1.0-SNAPSHOT

Description

The default tool result converter JSON-serializes every return value into a text block, apart from a returned ToolResultBlock that passes through. A tool wanting to produce typed output — say an ImageBlock with inline Base64 data — therefore had to wrap it in ToolResultBlock.of(...) itself; returning the block directly degraded it to a JSON string.

The converter now recognizes a returned ContentBlock, or a non-empty list whose elements are all ContentBlocks, and wraps it as the result's typed output. Mixed or empty lists keep the JSON path, so existing behavior is unchanged for ordinary values.

Changes

  • DefaultToolResultConverter.convert gains the ContentBlock and content-block-list branches; the class Javadoc lists the new rule.
  • Tests: single block wrapped unchanged, block list wrapped unchanged, mixed list still JSON, empty list still [].
  • EN/ZH tool docs describe the new return convention under "Explicit result states".

@jujn
jujn merged commit 693b4d3 into agentscope-ai:main Nov 21, 2026
4 of 5 checks passed
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