Skip to content

Conversation

ihower
Copy link
Contributor

@ihower ihower commented Sep 16, 2025

This PR adds a warning when agent names contain non-alphanumeric characters.
Such names are converted to underscores (_) when used as default function names in handoff or agent.as_tool.

In these cases, non-English or symbolic names may turn into the same function name (e.g. ____).
The server does not raise an error, but handoffs will fail silently or tools may be overwritten.
This is frustrating for developers when testing handoffs, as they will never be routed to the correct agent.

Reproduction Example

from agents import Agent, ModelSettings, Runner, handoff

agent2 = Agent(
    name="風林火山 Agent",
    model="gpt-5-mini",
    instructions="You always answer: tree and mountain.",
)

agent3= Agent(
    name="疾風迅雷 Agent",
    model="gpt-5-mini",
    instructions="You always answer: wind and thunder.",
)

agent = Agent(
    name="Assistant",
    model="gpt-5-mini",
    instructions="You always hand off to the 風林火山 agent.",
    handoffs=[agent2, agent3],
)

result =  Runner.run_sync(agent, "Tell me something about speed.")


print(result.final_output)

screenshot

Example warning output

Tool name 'transfer_to_風林火山_Agent' contains invalid characters for function calling and has been transformed to 'transfer_to______agent'. Please use only letters, digits, and underscores to avoid potential naming conflicts.
Tool name 'transfer_to_疾風迅雷_Agent' contains invalid characters for function calling and has been transformed to 'transfer_to______agent'. Please use only letters, digits, and underscores to avoid potential naming conflicts.

@ihower ihower force-pushed the add-agent-name-function-name-warning branch from ec17c65 to 7e877d9 Compare September 16, 2025 12:59
Copy link
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thanks for improving this. You're literally 疾風迅雷!

@seratch seratch merged commit e486b3a into openai:main Sep 17, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants