Skip to content

Conversation

@lbbniu
Copy link

@lbbniu lbbniu commented Dec 9, 2025

Summary

Enhanced HandoffBuilder._apply_auto_tools to use the target agent's description when creating handoff tools, providing more informative tool descriptions for LLMs.

Changes

  • Modified _apply_auto_tools in _handoff.py to extract description from AgentExecutor._agent when available
  • Updated iteration to use .items() for more efficient dict traversal
  • Handoff tools now use agent descriptions instead of generic placeholders

Example Impact

Before:

tool_description = "Handoff to the refund_agent agent."

After:

tool_description = "You handle refund requests. Ask for order details and process refunds."

Benefits

  • More informative handoff tool descriptions for LLMs
  • Better alignment with agent's actual purpose
  • Improved tool selection by the coordinator agent
  • No breaking changes to existing API

Testing

  • ✅ All handoff tests pass (20/20)
  • ✅ No regressions in existing functionality
  • ✅ Code follows project style guidelines

Files Modified

  • python/packages/core/agent_framework/_workflows/_handoff.py (lines 1088-1097)

Fixes #2713

…icrosoft#2713)

## Summary
Enhanced `HandoffBuilder._apply_auto_tools` to use the target agent's
description when creating handoff tools, providing more informative tool
descriptions for LLMs.

## Changes
- Modified `_apply_auto_tools` to extract `description` from
  `AgentExecutor._agent` when available
- Updated iteration to use `.items()` for more efficient dict traversal
- Handoff tools now use agent descriptions instead of generic placeholders

## Example
Before: "Handoff to the refund_agent agent."
After: "You handle refund requests. Ask for order details and process refunds."

## Testing
- All handoff tests pass (20/20)
- No breaking changes to existing API

Fixes microsoft#2713
Copilot AI review requested due to automatic review settings December 9, 2025 03:55
Copy link
Contributor

Copilot AI left a comment

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 enhances the HandoffBuilder to use agent descriptions when creating auto-generated handoff tools, making the tool descriptions more informative for LLMs when selecting which agent to hand off to.

  • The _apply_auto_tools method now extracts the description from the wrapped agent in AgentExecutor instances
  • Changed dictionary iteration to use .items() for more efficient traversal when both keys and values are needed
  • Handoff tools now use agent descriptions when available, falling back to generic descriptions otherwise

@moonbox3 moonbox3 added agent orchestration Issues related to agent orchestration workflows Related to Workflows in agent-framework labels Dec 9, 2025
@markwallace-microsoft
Copy link
Member

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework/_workflows
   _handoff.py51814072%58, 71–73, 80–81, 83, 85, 159, 167–172, 175–176, 190, 199, 218–221, 230–232, 243, 246, 256–267, 269, 275, 281, 316, 362, 455, 464–469, 471–472, 483, 500, 518, 533, 545, 573, 585–587, 593, 617–619, 622–625, 627–629, 872, 878, 882, 888, 892, 904, 954, 957, 1045, 1050, 1060, 1066–1069, 1077–1078, 1082–1084, 1086–1090, 1093–1097, 1099–1104, 1106–1107, 1109, 1111, 1126–1127, 1130–1131, 1134, 1154–1160, 1162, 1168, 1202–1203, 1256–1257, 1342, 1503, 1511, 1583, 1595, 1599, 1604–1605
TOTAL16288255184% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
2324 130 💤 0 ❌ 0 🔥 58.900s ⏱️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent orchestration Issues related to agent orchestration python workflows Related to Workflows in agent-framework

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Python: HandoffBuilder: Use agent description in auto-generated handoff tools

3 participants