Key resources
Below sections contain the key take aways from each lesson.
Overview
6 key components of multi-agent systems
Role playing
Focus
Tools
Cooperation
Guardrails
Memory
Interestingly, these components indeed makes for a great employee.
Multi-Agent Collab can be
- Sequential
- Parallel
- Hierarchical
- Asynchronous
Traditional Software Development vs. AI Software Development
Unlike traditional approach, AI Software Development has
- Fuzzy inputs
- Fuzzy transformations
- Fuzzy outputs
- Probabilistic nature
Lead Generation: Data Collection & Analysis Example
- Traditional Automation
- Website Visitor (e.g., Form) → Lead (e.g., >10 employees) → Sales (Low/Med/High Priority)
- Agentic Automation
- Website Visitor → Lead → Crew of AI Agents → Sales, where the
- Crew of AI Agents could do
- Research (data collection)
- Comparison
- Scoring
- Talking points
AI Agents
Initial Building Blocks
- Agents
- Tasks
- Crews
Create agents to research and write an article (L2)
This lesson introduces us to the fundamental concepts of multi-agent systems, and get an overview of crewAI framework.
It's been seen that LLMs perform better when they are role playing.
Steps involved in creating a Multi AI Agent
- **Create
Agents
by providing themrole
,goal
,backstory
- Create
Tasks
by providing themdescription
,expected_output
, andagent
- Create
Crew
, a top-level organization that oversees the agents and tasks
The Agentic Crew
to research and write any article was assembled using 3 Agents
and 3 Tasks
, which are
- Content Planner
- Content Writer
- Editor For more details, refer this GitHub code
Key elements of AI agents
Agents work better when they are role playing, focused, have appropriate tools, allowed to cooperate, leveraging memory, and having some guardrails.
- Role Playing
- e.g., “Give me an analysis on tesla stock” vs. “you are a FINRA approved financial analyst. give me an analysis on tesla stock”.
- The later is more effective.
- e.g., “Give me an analysis on tesla stock” vs. “you are a FINRA approved financial analyst. give me an analysis on tesla stock”.
- Focus
If we mix things too much (e.g., too many tools, information, context, etc.), our models can loose important information, and hallucinate more.
Do not use one single agent to achieve everything.
- Tools
Two different ways to give Agents Tools
- Agent Level
- Task Level
- Cooperation
Ability to cooperate (take feedbacks, delegate tasks) and to bounce ideas of each other produces much better outcome.
- Guardrails
Prevent Agent from derailing and budge them to stay on track, thereby making sure to prevent hallucinations and we get reliable and consistent results.
- Memory
Memory makes huge, immense difference on our Agent.
3 types of memory offered by CrewAI out of the box:
- Short term memory
- Long term memory
- Entity memory
Multi agent customer support automation (L3)
This lesson covers the six key elements that help make AI Agents perform better.
The Agentic Crew
to provide customer support was assembled using 2 Agents
and 2 Tasks
Agents
support_agent
withrole="Senior Support Representative"
support_quality_assurance_agent
withrole="Support Quality Assurance Specialist"
andallow_delegation=True
, so that agent can delegate its work to another agent which is better suited to do a particular task.
Tool
docs_scrape_tool
that scrapes a 1 page (URL) of CrewAI documentation.
Tasks
inquiry_resolution
withtools=[docs_scrape_tool]
so that theAgent
can access thistool
on this specific-task.quality_assurance_review
Crew
crew
withmemory=True
to enable the Memory
Interestingly, the overall token cost of
gpt-4o-mini
is expensive thangpt-4o
, and it even made too many attempts which shows it's limitations.
For more details, refer this GitHub code
Mental framework for agent creation
Think as a Manager, as they are conditioned to think
- What is the Goal?
- What is the Process?
What kind of people would I need to hire to get this job done? What should be their roles, goals, backstories?
Those are the agents we want to build.
Example: Use case related to HR
Okay Agent 👎 | Better Agent 👍 |
---|---|
Researcher | HR Research Specialist |
Writer | Senior Copywriter |
Financial Analyst | FINRA Approved Analyst |
Key elements of agent tools
What makes a great Tool?
- Verstaile
- Fault-tolerant
- Cache
Tools is the connection between AI apps (that have fuzzy inputs) and the external world (that have strongly typed inputs).
CrewAI support Cross-agent caching
For more details, refer [Available CrewAI Tools] (https://docs.crewai.com/en/concepts/tools#available-crewai-tools).
We can also use all the tools that LangChain offers.
Tools for a customer outreach campaign (L4)
This lesson covers more about tools, including custom ones
The Agentic Crew
to perform customer outreach campaign (drafting different emails for different target audience) was assembled using 2 Agents
, 4 Tools
, and 2 Tasks
Agents
sales_rep_agent
withrole=Sales Representative
lead_sales_rep_agent
withrole=Lead Sales Representative
Tool
directory_read_tool
that list files in directoryfile_read_tool
that reads file contentssearch_tool
(fromSerperDevTool
) to search the internet with Serpersentiment_analysis_tool
(custom tool) that’s hardcoded output
Tasks
lead_profiling_task
withtools=[directory_read_tool, file_read_tool, search_tool]
personalized_outreach_task
withtools=[sentiment_analysis_tool, search_tool]
Crew
crew
withmemory=True
to enable the Memory
For more details, refer this GitHub code
Key elements of well defined tasks
What tasks and processes do I expect the individuals on my team to do?
Those are the tasks we want to create.
Two key elements of well defined tasks
- Clear description of the tasks
- Set a clear and concise expectation
Other (hyper)parameters or task attributes
- Set context
- By using
context
, we can specify other tasks whose outputs will be used as context for this task.
- By using
- Set a callback
- By using
callback
, we can specify the Function/object to be executed after task completion.
- By using
- Override Agent tools with specific task tools
- By using
tools
, we can specify the tools/resources the agent is limited to use for this task.
- By using
- Force human input before end of task
- By setting
human_input=True
, the task will ask for human feedback (whether you like the results or not) before finalising it.
- By setting
- Execute asynchronously
- Output as Pydantic
- By using
output_pydantic
- By using
- Output as JSON
- By using
output_json
, you can specify the structure of the output you want.
- By using
- Output as file
- By using
output_file
, you can get your output in a file.
- By using
- Run in parallel
- By using
async_execution=True
, we can specify the task should be executed asynchronously. Defaults toFalse
.
- By using
For more details, refer crew ai documentation > tasks
Automate Event Planning (L5)
This lesson covers about tasks, and different parameters for it.
The Agentic Crew
to perform automated event planning was assembled using 3 Agents
, 2 Tools
, 3 Tasks
Agents
venue_coordinator
withtools=[search_tool, scrape_tool]
logistics_manager
withtools=[search_tool, scrape_tool]
marketing_communications_agent
withtools=[search_tool, scrape_tool]
Interestingly,
tools
are passed directly intoAgents
unlike previous examples, where they are passed only to thetools
- Class
VenueDetails
usingPydantic BaseModel
Tasks
venue_task
withhuman_input=True
,output_json=VenueDetails
, andoutput_file="venue_details.json"
logistics_task
withhuman_input=True
marketing_task
withasync_execution=True
andoutput_file="marketing_report.md"
Crew
The
human_input=True
turned out to be useful for providing feedback on the Final Result and Agent's actions.
For more details, refer this GitHub code
Multi agent collaboration for financial analysis (L6)
This lesson covers on ways to make agents collaborate with each other.
The multi Agentic Crew
to perform financial analsyis was assembled using 4
Agents, 2 Tools
, and 3 Tasks
Agents
data_analyst_agent
trading_strategy_agent
execution_agent
risk_management_agent
Note: All theAgents
were givenallow_delegation=True
, andtools=[scrape_tool, search_tool]
Tasks
data_analysis_task
strategy_development_task
execution_planning_task
risk_assessment_task
Note: All theTasks
were configured withoutput_file
to output a markdown file.
Crew
crew
withprocess=Process.hierarchical
Why hierarchical process instead of sequential process?
For a financial trading crew with multiple specialized agents, the hierarchical process is likely more appropriate as it allows for better coordination between the data analyst, strategy developer, execution agent, and risk manager, rather than forcing them to work in strict sequence.
For more details, refer this GitHub code
Build a crew to tailor job applications (L7)
This lesson covers building our first multi-agent system
The multi Agentic Crew
to perform tailored job applications using 4 Agents
, 3
Agents
researcher
withrole="Tech Job Researcher"
profiler
withrole="Personal Profiler for Engineers"
resume_strategist
withrole="Resume Strategist for Engineers"
interview_preparer
withrole="Engineering Interview Preparer"
Note: All theAgents
were giventools=[scrape_tool, search_tool, read_resume, semantic_search_resume]
, exceptresearcher
which was only giventools=[scrape_tool, search_tool]
Tasks
research_task
withoutput_file
as markdown andasync_execution=True
to extract job requirementsprofile_task
withoutput_file
as markdown andasync_execution=True
to compile comprehensive profileresume_strategy_task
withoutput_file
as markdown andcontext=[research_task, profile_task]
to align resume with job requirementsinterview_preparation_task
withoutput_file
as markdown andcontext=[research_task, profile_task, resume_strategy_task]
to develop interview materials
How does
context
work inTasks
?
- You can pass a list of tasks as
context
to a task.- The task then takes into account the output of those tasks in its execution.
- The task will not run until it has the output(s) from those tasks.
Next steps with AI Agent Systems
Check out these resources
- Crew AI related
- Others
To do or clarify
- Multi agent customer support automation (L3)
- When we set
Crew(..., memory=True)
, does it enable short-term memory or long-term memory? How about entity memory? - Citation is not provided in the demo output. Is it a glitch or something else?
- Seems this is resolved once migrated to latest GPT 4 variant models
- What’s considered as guardrail in this project?
- Is it the
expected_output
defined in theTask
orbackstory
provided in theAgent
or something else?
- Is it the
- When we set
- Tools for a customer outreach campgain (L4)
- Does this tool has caching with a timeout so that we don’t have to pay again for the same call for same query in a short span?
- What’s
cached_promot_tokens
inresult.token-usage
- For e.g., Token Usage: total_tokens=67180 prompt_tokens=65040 cached_prompt_tokens=51200 completion_tokens=2140 successful_requests=15 for gpt-4o
- Automate Event Planning (L5)
- When
async_execution=True
was enabled for two tasks, it’s throwing an error. How to fix it?
- When