Open
Description
Instantiating an Agent
with a non-string name
(e.g. an integer) does not perform type validation, causing downstream errors when the SDK assumes name
is a string.
from agents import Agent
# Pass an integer instead of a string
agent = Agent(name=1)
# Use the agent
response = agent.run_sync(agent , "Hello!")
Observe: no exception is raised at instantiation, but later calls fail (e.g. JSON serialization errors).
Sloution for this behavior:
if not isinstance(name, str):
raise TypeError(f"Agent name must be a string, got {type(name).__name__}")