Skip to content

fix: Enforce string type for Agent 'name' parameter - #1340

Closed
Hafiz-Muhammad-Umar12 wants to merge 1 commit into
openai:mainfrom
Hafiz-Muhammad-Umar12:improve-code
Closed

fix: Enforce string type for Agent 'name' parameter#1340
Hafiz-Muhammad-Umar12 wants to merge 1 commit into
openai:mainfrom
Hafiz-Muhammad-Umar12:improve-code

Conversation

@Hafiz-Muhammad-Umar12

Copy link
Copy Markdown
Contributor

This Pull Request addresses an inconsistency between the documentation and the runtime behavior of the Agent class.

The issue identified:

  • The documentation for the Agent class states that the name property is a required string.
  • However, the code did not strictly enforce this, allowing non-string values (e.g., integers) to be passed without raising an error. This could lead to unexpected behavior in downstream components and creates confusion for developers.

The solution:

  • A runtime check has been added to the __post_init__ method of the AgentBase class.
  • This check now strictly enforces that the name parameter must be a string, raising a TypeError if an invalid type is provided.

Why this is important:

  • Consistency: The code now accurately reflects what is stated in the documentation, making the SDK more reliable.
  • Clarity: Developers will receive an immediate and clear error message if they attempt to use an incorrect type, significantly

@seratch seratch added the duplicate This issue or pull request already exists label Aug 1, 2025
@seratch

seratch commented Aug 1, 2025

Copy link
Copy Markdown
Member

Thanks for sending this. We're going to resolve this issue by #998

@seratch seratch closed this Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants