How to ensure collaboration & file sharing between agents

Hi,

I am building a CV optimisation crew with three agents, I want cv_writer agent to write the cv and recruiter and hr_manager agents to give feedback on it and then cv writer to improve it until its accepted by hr manager.

I have instructed agents to collaborate in ‘goal’ and task ‘description’ but they don’t seem to collaborate in verbose output. I have read documentation I have enabled all params as far as I know

Question 1: Where should collaboration instruction should be added, ‘goal’ or task ‘description’?
Question 2: What is the best way to pass input data to agent? pass multiple file path in goal or multiple instance of FileReadTool in tools?
Question 3: Do I need 4th task at end to collate feedback and write improved cv? if yes then I have to duplicate all task ‘n’ no. of times which doesn’t seem smart

Here is my code

import os
from typing import List
from crewai import Agent, Task, Process, Crew, LLM
from langchain_community.tools import DuckDuckGoSearchRun
from crewai_tools import tool, FileReadTool
from langchain_openai import ChatOpenAI
from dotenv import load_dotenv
from loguru import logger

# Load environment variables from .env file
load_dotenv()

# To allow the agent to read any file:
file_read_tool = FileReadTool()
cvpath = "cv.txt"
jobspecpath = "jobspec.txt"
final_cvpath = "final_cv.txt"

# Or, multiple instances of fileReadTool
cv = FileReadTool(file_path=cvpath)
jobspec = FileReadTool(file_path=jobspecpath)
final_cv = FileReadTool(file_path=final_cvpath)

# Access API keys
api = os.getenv("OPENAPI_API_KEY")

llm = ChatOpenAI(model="gpt-4o", temperature=0.7, api_key=api)
# llm=LLM(model="ollama/llama3", base_url="http://localhost:11434") #didn't understand file paths in goals

# Tools
@tool('DuckDuckGoSearch')
def search(search_query: str):
    """Search the web for information on a given topic"""
    return DuckDuckGoSearchRun().run(search_query)

cvExpert = Agent(
    role="Resume writing expert",
    goal=f"""Produce a CV that is impactful and noticeable to the employer and passes the ATS filtering system. write the new CV after comparing
    less optimised cv {cvpath}  with job description {jobspecpath}. Share the CV with recruiter for feedback and then improve it till they are satisfied
    """,
    backstory="""You are a professional resume writing expert who knows how to make a CV impactful and noticeable. You know the latest trends of CV writing, pitfalls and ATS ranking. There is huge competition in the job market and you know how to make a CV that stands out from the crowd. You know how to make a CV that has 100% skills and responsibilities match with the job description. You research the company and ensure CV stikes the right chord with the employer. You always use facts and achievements from the attached or given initial cv for accuracy. You also ask questions if a skills or responsibilities is required in the job description and not present in the CV so you can add it in.
	""",
    tools=[file_read_tool],
    verbose=True, 
    allow_delegation=True,
    llm=llm
)

recruiter = Agent(
    role="HR recruiter",
    goal=f"""You are a HR recruiter who wants to pick a PM candidate who best matchs skills, is impact driven, fulfills all job requirements as per 
    {jobspecpath} compared to {final_cvpath}. Share your feedback with resume writer and then wait for the improved cv from him until you are satisfied
    """,
    backstory="""You are a HR recruiter who wants to pick a PM candidate who the best match of skills and responsibilities of the job description. You receive 100's of CV for this job and you are over whelmed. You relay on ATS to shortlist the CVs. You want CVs to be easy to scan, to the point yet highlights the skills and responsibilities, results and impact. You can only pick 2 to 3 candidates for the screening so you make sure this PM CV is the best amoung all by observing that how closely skills are matching the work experience.
    """,
    tools=[file_read_tool],
    verbose=True,
    allow_delegation=True,
    llm=llm
)

hiringManager = Agent(
    role="Hiring manager",
    goal=f"""You are a hiring manager who wants to ensure you hire a product manager who matches skills, requirements of the job description in {jobspecpath} compared to {final_cvpath}. Share the your feedback with recruiter and then wait for imporved cv from him until you are satisfied
    """,
    backstory="""You are hiring manager who wants to hire a product manager who has delivered top results in the past. That PM is outcomes focused. you are not impressed by just buzzwords but by the results and achievements. You wants to see how you have used soft, hard skills and responsibilities in the past to deliver results. You want to ensure this person is a good fit for the company culture and can work with the team. You want to ensure that this person is team player and leader. 
    """,
    tools=[file_read_tool],
    verbose=True,  # enable more detailed or extensive output
    allow_delegation=True,  # enable collaboration between agent
    llm=llm
)

tasks: List[Task] = [
    Task(
        description="""
        These keywords must never be translated and transformed:
            - Action:
            - Thought:
            - Action Input:
            because they are part of the thinking process instead of the output.
            Analyze deeply the less optimised cv 'cv.txt' & 'jobspec.txt' Develop an understanding what must be improved in this cv to make it impactful and noticeable to the employer. Write a a new CV that is highly impactful, results oriented and has 100% skills and responsibilities match with the job description. After you have written the new cv as per the jobspec.txt, share it with recruiter, collect feedback, improve the cv
        """,
        expected_output = """
           well formatted cv with 100% skills and responsibilities match with the job description in following format. 
           Here are the format of the cv:
           - name
              - contact details
            - professional summary
            - skills
            - work experience
                - 4 lines of most relevant work experience as per the job description
            - education
        """,
        output_file="final_cv.txt",
        agent=cvExpert
    ),

    Task(
        description="""
        Check the new CV produced by the resume writing expert. Analyze the CV against the job description to ensure that the CV is 100% match and exceed your expectations. Compare this CV against all oterh CVs you have received for this job. Pinpoint what is missing in the CV that if not added then this candidate will not be shortlisted. 
        """,
        expected_output="""
            - What improvements are needed in Professional summary 
            - Missing Skills 
            - improvements for each job in Work experience
            """,
        agent=recruiter
    ),

    Task(
        description="""
        Check the CV sent to you by the recruiter. Analyze the CV against the job description to ensure that the contents of the CV represent the perfect candidate for this job. This CV makes you exicted to meet this candidate. If the CV is not ticking the right boxes, provide feedback to the recruiter so they can send you CVs that match your requirements. Share your impression of the CV with the recruiter so he knows what is the standard of the CVs you are you looking for.
        """,
        expected_output = """
            - Impression of the professional summary
            - Impression of the skills
            - Impression of the work experience
                - Which part of the work experience is most impressive
                - whcih part of the work experience is missing
                - whcih part of the work experience is not relevant
                - which part of the work experience is not impactful
            """,
        agent=hiringManager
    )
]
crew = Crew(
    agents=[cvExpert, hiringManager, recruiter],
    model="gpt-4o"
    tasks= tasks,
    cache=True,
    verbose=True,
    process=Process.sequential,  
    planning=True,
    planning_llm=llm
)

try:
    result = crew.kickoff()
    logger.info("Analysis completed successfully")
    print("######################")
    print(result)
    print(crew.usage_metrics)
except Exception as e:
    logger.error(f"Error during analysis: {str(e)}")

Direct instructions for collaborations can be added anywhere in ‘goal’ or ‘descriptions’ there are no set rules.

After some research I understand, reconciled and tweaked my approach to collaboration. Leanings are
a) allow_delegation:True is permission for the agent to delegate the task or not - choice remains with agent - due to fuzzy logic of inputs & outputs its the agent that decided when to reach out and when not to.
b) Agents Interpretation of collaboration keywords in goal or description are depended on type of LLM, its size and its training.
c) To increase the chance of collaboration make your agents more focused, with their role and back story. This is a signal for other agents to reach out to a specialist when they deem necessary source