Skip to content

feat: enhance input validation for Agent and Crew#4893

Open
gilangjavier wants to merge 4 commits intocrewAIInc:mainfrom
gilangjavier:improve/core-logic-enhancement
Open

feat: enhance input validation for Agent and Crew#4893
gilangjavier wants to merge 4 commits intocrewAIInc:mainfrom
gilangjavier:improve/core-logic-enhancement

Conversation

@gilangjavier
Copy link

@gilangjavier gilangjavier commented Mar 15, 2026

This PR introduces stricter input validation for core components to prevent common initialization errors.

Changes:

  • BaseAgent: Added validators for role, goal, and backstory to ensure they are not empty or whitespace-only strings.
  • Crew: Improved _create_task to provide a descriptive ValueError with available roles if a specified agent is not found, instead of a silent StopIteration.

These enhancements help developers catch configuration issues early during the development phase.


Note

Low Risk
Low risk: adds stricter Pydantic validation and replaces a StopIteration with a clearer ValueError, which may surface previously-silent misconfigurations as early failures.

Overview
Adds stricter input validation for BaseAgent by rejecting empty/whitespace-only values for role, goal, and backstory at model validation time.

Improves Crew config task creation by raising a descriptive ValueError when a task references a missing agent role (including a list of available roles) instead of bubbling a StopIteration.

Includes small docstring/field description grammar fixes in Crew and Task.

Written by Cursor Bugbot for commit 2c149b3. This will update automatically on new commits. Configure here.

- Corrected "it's" to "its" in several docstrings.
- Fixed missing possessive apostrophes (e.g., "agents execution" -> "agents' execution").
- Capitalized first word in attribute descriptions for consistency.
- Fixed "execution the task" to "executing the task".
- Updated wording in docstrings to improve clarity and consistency.

These changes improve documentation quality without altering any code logic.
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

This prevents noisy tracebacks showing the internal StopIteration
when an unknown agent role is specified.
@gilangjavier
Copy link
Author

Thanks for the review! The exception chaining issue has been fixed by adding 'from None' to the ValueError raise statement. This suppresses the noisy StopIteration traceback and provides a cleaner error message. The fix has been pushed to the branch.

@gilangjavier
Copy link
Author

Merged latest into this branch to resolve BEHIND status (merge commit: c0bacce).

@gilangjavier
Copy link
Author

Merged latest main into this branch to resolve BEHIND status.

Merge commit: c0bacce

@gilangjavier
Copy link
Author

Merged main and pushed the branch update. If any required checks need to be re-triggered after the merge commit, please kick them off and I’ll address anything that comes up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant