Address PR feedback: Add validation, error handling, refactoring, and tests

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-03-20 08:57:19 +00:00
parent 0ff73d22d7
commit d82a01d4f7
4 changed files with 106 additions and 25 deletions

View File

@@ -196,6 +196,14 @@ class Task(BaseModel):
"If return type is annotated, it must be Tuple[bool, Any]"
)
return v
@field_validator("ask_human_input")
@classmethod
def validate_ask_human_input(cls, v: Optional[Callable]) -> Optional[Callable]:
"""Validate that the ask_human_input function is callable."""
if v is not None and not callable(v):
raise ValueError("ask_human_input must be a callable function")
return v
_original_description: Optional[str] = PrivateAttr(default=None)
_original_expected_output: Optional[str] = PrivateAttr(default=None)