Skip to content

feat(mcp): add title field to tool call chain for human-readable display#1914

Open
amyaxy wants to merge 3 commits into
agentscope-ai:mainfrom
amyaxy:feat/add_support_title_for_mcp_tool
Open

feat(mcp): add title field to tool call chain for human-readable display#1914
amyaxy wants to merge 3 commits into
agentscope-ai:mainfrom
amyaxy:feat/add_support_title_for_mcp_tool

Conversation

@amyaxy

@amyaxy amyaxy commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Add an optional title field throughout the tool invocation pipeline, providing a human-readable label alongside the machine-oriented name. When no title is defined, consumers should fall back to name for display.

Feature changes:

  • AgentTool: add default getTitle() returning getName()
  • ToolBase / ToolSchema / SchemaOnlyTool / McpTool: support title in builder & getter
  • ToolUseBlock / ToolResultBlock: add title field, withTitle(), withIdAndNameAndTitle()
  • Event classes (ToolCallStart/End, ToolResultStart/End): add toolCallTitle
  • ToolUtils: new resolveToolTitle() to look up title from Toolkit
  • LegacyHookDispatcher / ReActAgent: resolve and set title on ToolUseBlock
  • ToolResultMessageBuilder: propagate title from originalCall
  • ToolSchemaProvider: pass tool.getTitle() when building schema
  • AsyncToolMiddleware / PlanModeMiddleware: pass title through events

Test changes:

  • NEW: ToolUtilsTest, ToolSchemaTest, ToolResultBlockTest, ToolResultMessageBuilderTest (~36 test cases)
  • EXTEND: ToolUseBlockTest, ToolBaseTest, SchemaOnlyToolTest, AsyncToolMiddlewareTest (~14 additional test cases)

AgentScope-Java Version

2.0.0-SNAPSHOT

Description

close #1590

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

…play

Add an optional `title` field throughout the tool invocation pipeline,
providing a human-readable label alongside the machine-oriented `name`.
When no title is defined, consumers should fall back to `name` for display.

Feature changes:
- AgentTool: add default getTitle() returning getName()
- ToolBase / ToolSchema / SchemaOnlyTool / McpTool: support title in builder & getter
- ToolUseBlock / ToolResultBlock: add title field, withTitle(), withIdAndNameAndTitle()
- Event classes (ToolCallStart/End, ToolResultStart/End): add toolCallTitle
- ToolUtils: new resolveToolTitle() to look up title from Toolkit
- LegacyHookDispatcher / ReActAgent: resolve and set title on ToolUseBlock
- ToolResultMessageBuilder: propagate title from originalCall
- ToolSchemaProvider: pass tool.getTitle() when building schema
- AsyncToolMiddleware / PlanModeMiddleware: pass title through events

Test changes:
- NEW: ToolUtilsTest, ToolSchemaTest, ToolResultBlockTest,
        ToolResultMessageBuilderTest (~36 test cases)
- EXTEND: ToolUseBlockTest, ToolBaseTest, SchemaOnlyToolTest,
          AsyncToolMiddlewareTest (~14 additional test cases)
@amyaxy amyaxy requested a review from a team June 25, 2026 11:48
@itxaiohanglover

Copy link
Copy Markdown
Contributor

Really thorough work threading the title field through the entire chain — backward compat with the old constructors is well done. One thing I noticed: ToolBase.getTitle() returns the raw title field which can be null, but AgentTool.getTitle() has a default that returns getName(). So a ToolBase without a title returns null instead of falling back to the name, which feels inconsistent. Might be worth having ToolBase.getTitle() return title != null ? title : getName(). Other than that, nice PR.

amyaxy added 2 commits June 26, 2026 14:22
If not provided, the name should be used for display.
@amyaxy

amyaxy commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

@chickenlj 辛苦抽空帮忙看下这个PR,谢谢

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.

[Feature]: Support title for McpTool

2 participants