Handoff auto-name with spaces builds OK but fails in convert_tools / AssistantAgent.run
Describe the bug
Handoff validates a custom name with str.isidentifier(), but the auto-generated default transfer_to_{target} is not validated or slugified. If target contains spaces (e.g. "Support Desk"), construction and AssistantAgent(..., handoffs=[...]) succeed, then the first model call fails in OpenAI convert_tools with Invalid name: transfer_to_support desk.
To Reproduce
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.base import Handoff
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_ext.models.openai._openai_client import convert_tools
async def main() -> None:
handoff = Handoff(target="Support Desk")
print("auto name:", repr(handoff.name), "isidentifier:", handoff.name.isidentifier())
# -> 'transfer_to_support desk' False
convert_tools([handoff.handoff_tool]) # ValueError: Invalid name: transfer_to_support desk
client = OpenAIChatCompletionClient(model="gpt-4o", api_key="sk-fake")
agent = AssistantAgent("triage", model_client=client, handoffs=["Support Desk"])
await agent.run(task="Please transfer me to support") # same ValueError
asyncio.run(main())Expected behavior
Either slugify auto names (e.g. transfer_to_support_desk) or reject invalid targets at construction with the same rules as custom name, so agents do not fail only at runtime.
Actual behavior
Construction succeeds; failure is deferred to convert_tools / AssistantAgent.run.
Environment
autogen-agentchat/autogen-core/autogen-ext0.7.5- Python 3.13
Additional context
Root cause appears to be the default-name path in autogen_agentchat.base._handoff.Handoff skipping the identifier check that custom names get.
Source: microsoft/autogen