Skip to content

Add tool name and description override functionality to Workbench implementations #6690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 18, 2025

This PR implements modifiable tool names and descriptions for both StaticWorkbench and McpWorkbench as requested in the issue. The implementation allows users to customize how tools appear to consumers while maintaining the underlying tool functionality.

Key Features

ToolOverride Model

  • New ToolOverride Pydantic model with optional name and description fields
  • Supports partial overrides (name only, description only, or both)
  • Full serialization/deserialization support

StaticWorkbench Enhancements

  • Optional tool_overrides parameter in constructor
  • Applies overrides in list_tools() while preserving original tool parameters
  • Maps override names back to original names in call_tool() for seamless execution
  • Conflict detection prevents duplicate or conflicting override names
  • Maintains backward compatibility - existing code continues to work unchanged

McpWorkbench Enhancements

  • Client-side tool override mapping for server-side tools
  • Override names are mapped back to original server tool names during execution
  • Duplicate override name validation
  • Preserves all existing MCP functionality

Usage Examples

from autogen_core.tools import StaticWorkbench, ToolOverride

# StaticWorkbench with overrides
overrides = {
    "multiply": ToolOverride(name="calculate_product", description="Advanced multiplication tool"),
    "format": ToolOverride(description="Enhanced text formatting")  # Description only
}
workbench = StaticWorkbench(tools=[multiply_tool, format_tool], tool_overrides=overrides)

# Tools appear with new names/descriptions
tools = await workbench.list_tools()
# tools[0]["name"] == "calculate_product" 
# tools[0]["description"] == "Advanced multiplication tool"

# Call using override name
result = await workbench.call_tool("calculate_product", {"a": 6, "b": 7})
from autogen_ext.tools.mcp import McpWorkbench, ToolOverride

# McpWorkbench with server tool overrides
overrides = {
    "fetch": ToolOverride(name="web_scraper", description="Advanced web content fetching")
}
workbench = McpWorkbench(server_params=params, tool_overrides=overrides)

# Server's "fetch" tool appears as "web_scraper" with new description
# Calls to "web_scraper" are automatically mapped to server's "fetch" tool

Implementation Details

  • Reverse mapping: Efficient lookup from override names to original names for tool execution
  • Conflict detection: Validates that override names don't conflict with existing tool names or duplicate other overrides
  • Type safety: Proper TypedDict handling for ToolSchema creation
  • Error handling: Clear error messages for conflicts and missing tools
  • Serialization: Full support for saving/loading workbench configurations with overrides

Testing

  • Comprehensive test suite covering all functionality and edge cases
  • Conflict detection validation
  • Serialization/deserialization testing
  • Partial override scenarios
  • Backward compatibility verification

Backward Compatibility

All existing code continues to work without changes. The tool_overrides parameter is optional and defaults to no overrides.

Fixes #6689.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits June 18, 2025 00:44
…bench and McpWorkbench

Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
…tionality

Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Making Workbench tool names and descriptions modifiable properties to allow for optimization Add tool name and description override functionality to Workbench implementations Jun 18, 2025
@Copilot Copilot AI requested a review from ekzhu June 18, 2025 00:51
Copilot finished work on behalf of ekzhu June 18, 2025 00:51
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.

Making Workbench tool names and descriptions modifiable properties to allow for optimization
2 participants