Hello team,
And nice to meet you as I’m new here.
I’m discovering the crew AI magic
I have a crew with 2 agents:
- file_transformation_developer
- code_checker, that has a custom tool to execute code on an online sandbox.
I have 2 related tasks:
- code_development
- code_check
When using sequential process, the code works perfectly. The developer generates python code, that is then executed by the code checker.
Now I want to build a hierarchical process.
I’ve built a team lead manager. This manager first delegate the code generation to the code developer. Then, the code is tested by the code checker.
However, at this point, the code checker always generates it’s own code.
I’ve put clear, upper letters instructions in agent config for code_checker agent not to generate it’s own code.
I think the problem is, the code_checker don’t get the output of the code developper.
Thanks a lot for your help,
Best,
Marc
crew.py
from crewai import Agent, Crew, Process, Task
from crewai.project import CrewBase, agent, crew, task
from flow.tools import code_executor
@CrewBase
class FileTransformationCodingCrew():
"""File Transformation Coding Crew"""
agents_config = 'config/agents.yaml'
tasks_config = 'config/tasks.yaml'
@agent
def file_transformation_developer_team_lead(self) -> Agent:
return Agent(
config=self.agents_config['file_transformation_developer_team_lead'],
verbose=True,
memory=True,
allow_code_execution=False,
)
@agent
def file_transformation_developer(self) -> Agent:
return Agent(
config=self.agents_config['file_transformation_developer'],
verbose=True,
memory=True,
allow_code_execution=False,
allow_delegation=False,
)
@agent
def code_checker(self) -> Agent:
return Agent(
config=self.agents_config['code_checker'],
verbose=True,
memory=True,
tools=[code_executor.code_executor],
allow_code_execution=True,
allow_delegation=False,
)
@task
def code_development(self) -> Task:
return Task(
config=self.tasks_config['code_development'],
)
@task
def code_check(self) -> Task:
return Task(
config=self.tasks_config['code_check'],
context=[self.code_development()]
)
@crew
def crew(self) -> Crew:
"""Creates the File Transformation Coding Crew"""
return Crew(
process=Process.hierarchical,
agents=[self.file_transformation_developer(), self.code_checker()],
manager_agent=self.file_transformation_developer_team_lead(),
tasks=self.tasks,
memory=False,
verbose=True,
)
tasks.yaml
code_development:
description: >
Write the python script as per the specifications. Testing the script is not part of this task.
expected_output: >
The final answer must be the full python code, only the python code and nothing else.
agent: file_transformation_developer
code_check:
description: >
Execute the code built in the code_development task. Check for errors in the execution, validates output files against specifications.
expected_output: >
Report on any bugs or issues, and confirmation that the expected output files are created.
agent: code_checker