Skip to content

str allows int value without error in Agent constructor #1032

Closed
@shirazkk

Description

@shirazkk

Hi OpenAI team 👋

I noticed something while working with the Agent class in the OpenAI Agent SDK.

According to the SDK, the name field in the Agent class is typed as str, like this:

class Agent(...):
    name: str

However, when I pass an integer like 1 to the name parameter, it still works without raising any validation error:

agent = Agent(name=1)
print(agent.name)  # Output: 1

🔍 My Questions:

  1. Is this expected behavior due to Pydantic's automatic type coercion?
  2. Should this be allowed in strict type-checking scenarios?
  3. Is there a way to enforce stricter typing for critical fields like name?

Thanks for your great work on this amazing SDK! 🙏


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