diff --git a/src/crewai/project/annotations.py b/src/crewai/project/annotations.py index fefbad884..d315edace 100644 --- a/src/crewai/project/annotations.py +++ b/src/crewai/project/annotations.py @@ -103,7 +103,8 @@ def crew(func): for task_name in sorted_task_names: task_instance = tasks[task_name]() instantiated_tasks.append(task_instance) - if hasattr(task_instance, "agent"): + agent_instance = getattr(task_instance, "agent", None) + if agent_instance is not None: agent_instance = task_instance.agent if agent_instance.role not in agent_roles: instantiated_agents.append(agent_instance) diff --git a/src/crewai/project/crew_base.py b/src/crewai/project/crew_base.py index 5e0f154ea..3bad0b608 100644 --- a/src/crewai/project/crew_base.py +++ b/src/crewai/project/crew_base.py @@ -27,7 +27,9 @@ def CrewBase(cls): tasks_config_path = self.base_directory / self.original_tasks_config_path self.agents_config = self.load_yaml(agents_config_path) + print("agent_config", self.agents_config) self.tasks_config = self.load_yaml(tasks_config_path) + print("task_config", self.tasks_config) self.map_all_agent_variables() self.map_all_task_variables() @@ -136,6 +138,8 @@ def CrewBase(cls): output_pydantic_functions, ) + print(f"config for task {task_name}:", self.tasks_config[task_name]) + def _map_task_variables( self, task_name: str, @@ -147,6 +151,7 @@ def CrewBase(cls): callback_functions: Dict[str, Callable], output_pydantic_functions: Dict[str, Callable], ) -> None: + # print("TASK INFO", task_info) if context_list := task_info.get("context"): self.tasks_config[task_name]["context"] = [ tasks[context_task_name]() for context_task_name in context_list @@ -175,4 +180,6 @@ def CrewBase(cls): callback_functions[callback]() for callback in callbacks ] + # print("FINAL TASK CONFIG", self.tasks_config) + return WrappedClass diff --git a/src/crewai/utilities/config.py b/src/crewai/utilities/config.py index 56a59ce1b..156a3e66b 100644 --- a/src/crewai/utilities/config.py +++ b/src/crewai/utilities/config.py @@ -23,17 +23,16 @@ def process_config( # Copy values from config (originally from YAML) to the model's attributes. # Only copy if the attribute isn't already set, preserving any explicitly defined values. for key, value in config.items(): - if key not in model_class.model_fields: + if key not in model_class.model_fields or values.get(key) is not None: continue - if values.get(key) is not None: - continue - if isinstance(value, (str, int, float, bool, list)): - values[key] = value - elif isinstance(value, dict): + + if isinstance(value, dict): if isinstance(values.get(key), dict): values[key].update(value) else: values[key] = value + else: + values[key] = value # Remove the config from values to avoid duplicate processing values.pop("config", None)