-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Support list of YAML files for agents_config and tasks_config in CrewBase #2722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Support list of YAML files for agents_config and tasks_config in CrewBase #2722
Conversation
…n CrewBase Co-Authored-By: Joe Moura <joao@crewai.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Disclaimer: This review was made by a crew of AI Agents. Code Review for PR #2722 — Multi-YAML Config Support in CrewBaseSummaryThis PR introduces the capability to specify multiple YAML configuration files for The implementation is robust, idiomatic, and well-covered with integration tests. The new feature will allow complex layered project configurations with explicit override support, a valuable enhancement for CrewBase users. Detailed Findings and Suggestions1. Code Quality and Improvementsa) Normalization of Input Types for Config PathsCurrent: Issue: Recommendation: if isinstance(self.original_agents_config_path, list):
agents_config_paths = [self.base_directory / p for p in self.original_agents_config_path]
else:
agents_config_paths = [self.base_directory / self.original_agents_config_path]
# Same for tasks This normalization simplifies b) Merge Behavior: Shallow vs Deep MergeCurrent:
Implications: Options:
def deep_merge(dict1, dict2):
result = dict1.copy()
for k, v in dict2.items():
if k in result and isinstance(result[k], dict) and isinstance(v, dict):
result[k] = deep_merge(result[k], v)
else:
result[k] = v
return result This can replace the current c) Error Handling and LoggingCurrent: Recommendation: import logging
def load_yaml(self, config_path: Path):
try:
# Load YAML
except FileNotFoundError:
logging.error(f"Configuration YAML file not found: {config_path}")
raise This allows better control of error visibility and integrates with existing logging systems. d) Type Annotations and Python Version Compatibility
from typing import Union, List
def load_and_merge_yaml_configs(self, config_paths: Union[List[Path], Path]) -> dict:
...
2. Tests and YAML Configurations
Suggestions:
3. Documentation and Usage Notes
4. Historical Context and Learned Patterns
5. Summary Table of Suggestions
Code Snippet Example: Improved Normalization and Deep Mergedef normalize_to_path_list(base_directory, paths):
if isinstance(paths, (list, tuple)):
return [base_directory / p for p in paths]
else:
return [base_directory / paths]
def deep_merge(dict1: dict, dict2: dict) -> dict:
result = dict1.copy()
for key, value in dict2.items():
if key in result and isinstance(result[key], dict) and isinstance(value, dict):
result[key] = deep_merge(result[key], value)
else:
result[key] = value
return result
def load_and_merge_yaml_configs(self, config_paths: list[Path]) -> dict:
result = {}
for path in config_paths:
config = self.load_yaml(path)
if config:
for key, val in config.items():
if key in result and isinstance(result[key], dict) and isinstance(val, dict):
result[key] = deep_merge(result[key], val)
else:
result[key] = val
return result Final ConclusionThis PR delivers a meaningful and user-oriented feature with a clean implementation and excellent tests. The improvements suggested here primarily target maintainability, robustness, logging practices, and clarity about merge semantics. By normalizing types and enhancing error handling, the feature will be even more solid and friendly for future developers. The addition of user documentation will help adoption. Overall, this is a valuable and well-crafted contribution to the crewAIInc/crewAI codebase. |
Co-Authored-By: Joe Moura <joao@crewai.com>
Support list of YAML files for agents_config and tasks_config in CrewBase
Description
This PR implements the feature requested in issue #2721. It allows the
agents_config
andtasks_config
attributes in the CrewBase decorator to accept a list of YAML file paths instead of just a single path string.Changes
__init__
method to use the new helper methodHow to use
Previously:
Now you can also do:
Configurations from multiple files are merged, with later files overriding earlier ones for duplicate keys.
Resolves #2721
Link to Devin run: https://app.devin.ai/sessions/e13afb9d30dd405a8b0066212f335934
Requested by: Joe Moura (joao@crewai.com)