- Notifications
You must be signed in to change notification settings - Fork2k
Added runtime validation for Agent name field#998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
…evelopers" appears twice in the classifiers list. Line Number 20 and Line Number 26 Fix: Removed the duplicate classifier entry
…he tracing module where one import uses an absolute path in line number 3 while all others use relative imports
seratch commentedJul 8, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Related to#996; if we add this, we may want to have validation logic for other arguments too@rm-openai any opinion? |
Thanks for the feedback! You're right that this could be part of a broader validation pattern. Looking at the Agent class, several other fields could benefit from similar runtime validation:
I'm happy if I can expand this PR to include other critical fields or use this as a foundation for incremental validation. What approach works best for the team? |
Agent class currently has 16 fields, so adding all of them may take some time. If you're fine with it, your contribution would be appreciated. Otherwise, we can later add validations to the rest of the fields after merging this PR only with name.
Simply writing all logic in
Checking if a value is not None and then check the type of the value would be enough. I don't think we should scan all the elements of an array and nested property values (i.e., no need to check internal values of |
I just noticed@rm-openai started refactoring of the class -#1044 ; aligning with this change and/or working on this PR after the refactoring is done would be appreciated 🙏 |
Ok! will work on this after refactoring 👍 |
@DanielHashmi The refactoring is done, and we've been receiving the same feedback from a few users. If you have time and interest to resume this PR work, it'd be appreciated! (Otherwise, I am happy to work on the rest 👋 ) |
Added 16 Validations & Some Critical Tests
I have added validations and some tests, Can you review it and tell me what should be my next step? |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Looks great to me
@rm-openai we've been receiving the same feedback about the lack of validation of inti params for Agent almost every day. Can you take a look at this change and include it in the upcoming release?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We could certainly add this, but I do wonder what the underlying issue is? Why are callsites setting non-string params?
@rm-openai people are not trying to intentionally pass non-string to the name property, but a few people reported that they are confused with unexpected runtime error later on when they set invalid ones. You can find the list of issues linked here:#996 Thus, having validation for Agent initialization should make sense. |
Uh oh!
There was an error while loading.Please reload this page.
Add
__post_init__
validation to ensure Agent name is a stringThe Agent class previously only used type hints for the name field without
runtime validation, allowing non-string values like integers to be passed.
This caused downstream errors during JSON serialization, tracing, and other
operations that expect the name to be a string.
Changes:
__post_init__
method to Agent class withisinstance
checkFixes issue where
Agent(name=1)
would succeed but cause errors laterin the execution pipeline.
Fixes#996