mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-22 14:48:13 +00:00
Fix task configuration with None context parameter in YAML
Fixes #3696 When context: None is specified in YAML, yaml.safe_load() converts it to the string 'None' instead of Python's None object. The code was attempting to iterate over this string character by character, causing KeyError: 'N' when trying to look up task names. Changes: - Added isinstance(context_list, list) check in crew_base.py before iterating context_list to handle YAML's conversion of None to string - Added test case test_task_with_none_context_from_yaml to verify tasks can be configured with context: None without errors - Added test YAML configurations in tests/config_none_context/ to reproduce and verify the fix The fix ensures that only actual list values are processed, allowing None and other non-list values to pass through without causing errors. Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
5
tests/config_none_context/agents.yaml
Normal file
5
tests/config_none_context/agents.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
test_agent:
|
||||
role: Test Agent
|
||||
goal: Test goal
|
||||
backstory: Test backstory
|
||||
verbose: true
|
||||
11
tests/config_none_context/tasks.yaml
Normal file
11
tests/config_none_context/tasks.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
task_with_none_context:
|
||||
description: A test task with None context
|
||||
expected_output: Some output
|
||||
agent: test_agent
|
||||
context: None
|
||||
|
||||
task_with_valid_context:
|
||||
description: A test task with valid context
|
||||
expected_output: Some output
|
||||
agent: test_agent
|
||||
context: [task_with_none_context]
|
||||
Reference in New Issue
Block a user