-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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 our terms of service and privacy 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
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 👍 |
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:
Fixes issue where Agent(name=1) would succeed but cause errors later
in the execution pipeline.