Skip to content

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

@lbbniu

Description

@lbbniu

Description

Currently, when HandoffBuilder._apply_auto_tools creates handoff tools for specialist agents, it doesn't use the agent's description. This means the auto-generated handoff tools have generic descriptions like "Handoff to the refund_agent agent" instead of more informative descriptions based on the actual agent's purpose.

Current Behavior

In _handoff.py:1160, the code calls:

tool = _create_handoff_tool(alias)

This creates a handoff tool with a generic description.

Expected Behavior

When the target Executor is an AgentExecutor, the code should extract the agent's description from AgentExecutor._agent.description and pass it to _create_handoff_tool:

description = None
executor = specialists.get(exec_id)
if isinstance(executor, AgentExecutor):
    agent = getattr(executor, '_agent', None)
    description = getattr(agent, 'description', None)

tool = _create_handoff_tool(alias, description)

Benefits

  • More informative handoff tool descriptions for LLMs
  • Better alignment with agent's actual purpose
  • Improved tool selection by the coordinator agent

Files to Modify

  • python/packages/core/agent_framework/_workflows/_handoff.py: Update _apply_auto_tools method (around line 1149-1172)

Related Code

  • _create_handoff_tool already accepts an optional description parameter (line 69)
  • AgentExecutor._agent provides access to the wrapped agent (line 94 in _agent_executor.py)

Metadata

Metadata

Assignees

Labels

agent orchestrationIssues related to agent orchestrationpythonv1.0Features being tracked for the version 1.0 GA

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions