Skip to content

Agent.name accepts non-str types despite docs specifying str #1351

@uroojfatima18

Description

@uroojfatima18

The Agent class allows non-string types (like int) to be passed as the name, even though the documentation specifies that name should be a str.

I tested this by passing an integer to name, and the agent still worked without throwing any error. This may lead to confusion or bugs when users expect strict type validation.

#name is an integer here instead of a string

agent = Agent(name=1, instructions="You are a helpful assistant.")

result = await Runner.run(agent, "Write a 5-line haiku about AI")

The SDK should raise a validation error if name is not a str, matching what the documentation says.

If the SDK is not using Pydantic or any strict type-checking internally, then either that should be added, or the documentation should clarify that it's loosely enforced.This would help avoid confusion for developers expecting strongly typed input.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions