Skip to content

No validation on the Agent constructor arguments #996

Open
@EngineerAbdullahIqbal

Description

@EngineerAbdullahIqbal

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__}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions