KEMBAR78
Add tool name and description override functionality to Workbench implementations by Copilot · Pull Request #6690 · microsoft/autogen · GitHub
Skip to content

Conversation

Copy link
Contributor

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 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 AI requested a review from ekzhu June 18, 2025 00:51
Copilot finished work on behalf of ekzhu June 18, 2025 00:51
@codecov
Copy link

codecov bot commented Jul 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.33%. Comparing base (e107674) to head (c8126b7).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6690      +/-   ##
==========================================
+ Coverage   80.26%   80.33%   +0.06%     
==========================================
  Files         232      232              
  Lines       17641    17688      +47     
==========================================
+ Hits        14160    14209      +49     
+ Misses       3481     3479       -2     
Flag Coverage Δ
unittests 80.33% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ekzhu ekzhu marked this pull request as ready for review July 6, 2025 16:41
@ekzhu ekzhu requested a review from victordibia July 6, 2025 16:44
@ekzhu ekzhu merged commit 0bd99ee into main Jul 6, 2025
68 checks passed
@ekzhu ekzhu deleted the copilot/fix-6689 branch July 6, 2025 20:39
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