mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-05-01 23:32:39 +00:00
Fix NoneType error in convert_with_instructions when agent is None
- Add None check for agent parameter before accessing attributes - Return original result with error message when agent is None - Add comprehensive tests covering None agent scenarios - Fixes GitHub issue #3017 Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -190,6 +190,13 @@ def convert_with_instructions(
|
||||
agent: Any,
|
||||
converter_cls: Optional[Type[Converter]] = None,
|
||||
) -> Union[dict, BaseModel, str]:
|
||||
if agent is None:
|
||||
Printer().print(
|
||||
content="Failed to convert text into a Pydantic model: No agent available for conversion. Using raw output instead.",
|
||||
color="red",
|
||||
)
|
||||
return result
|
||||
|
||||
llm = agent.function_calling_llm or agent.llm
|
||||
instructions = get_conversion_instructions(model, llm)
|
||||
converter = create_converter(
|
||||
|
||||
Reference in New Issue
Block a user