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
Agentsby providing themrole,goal,backstory - Create
Tasksby 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
Agentssupport_agentwithrole="Senior Support Representative"support_quality_assurance_agentwithrole="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.
Tooldocs_scrape_toolthat scrapes a 1 page (URL) of CrewAI documentation.
Tasksinquiry_resolutionwithtools=[docs_scrape_tool]so that theAgentcan access thistoolon this specific-task.quality_assurance_review
Crewcrewwithmemory=Trueto enable the Memory
Interestingly, the overall token cost of
gpt-4o-miniis 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
Agentssales_rep_agentwithrole=Sales Representativelead_sales_rep_agentwithrole=Lead Sales Representative
Tooldirectory_read_toolthat list files in directoryfile_read_toolthat reads file contentssearch_tool(fromSerperDevTool) to search the internet with Serpersentiment_analysis_tool(custom tool) that’s hardcoded output
Taskslead_profiling_taskwithtools=[directory_read_tool, file_read_tool, search_tool]personalized_outreach_taskwithtools=[sentiment_analysis_tool, search_tool]
Crewcrewwithmemory=Trueto 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
Agentsvenue_coordinatorwithtools=[search_tool, scrape_tool]logistics_managerwithtools=[search_tool, scrape_tool]marketing_communications_agentwithtools=[search_tool, scrape_tool]
Interestingly,
toolsare passed directly intoAgentsunlike previous examples, where they are passed only to thetools
- Class
VenueDetailsusingPydantic BaseModel Tasksvenue_taskwithhuman_input=True,output_json=VenueDetails, andoutput_file="venue_details.json"logistics_taskwithhuman_input=Truemarketing_taskwithasync_execution=Trueandoutput_file="marketing_report.md"
Crew
The
human_input=Trueturned 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
Agentsdata_analyst_agenttrading_strategy_agentexecution_agentrisk_management_agentNote: All theAgentswere givenallow_delegation=True, andtools=[scrape_tool, search_tool]
Tasksdata_analysis_taskstrategy_development_taskexecution_planning_taskrisk_assessment_taskNote: All theTaskswere configured withoutput_fileto output a markdown file.
Crewcrewwithprocess=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
Agentsresearcherwithrole="Tech Job Researcher"profilerwithrole="Personal Profiler for Engineers"resume_strategistwithrole="Resume Strategist for Engineers"interview_preparerwithrole="Engineering Interview Preparer"Note: All theAgentswere giventools=[scrape_tool, search_tool, read_resume, semantic_search_resume], exceptresearcherwhich was only giventools=[scrape_tool, search_tool]
Tasksresearch_taskwithoutput_fileas markdown andasync_execution=Trueto extract job requirementsprofile_taskwithoutput_fileas markdown andasync_execution=Trueto compile comprehensive profileresume_strategy_taskwithoutput_fileas markdown andcontext=[research_task, profile_task]to align resume with job requirementsinterview_preparation_taskwithoutput_fileas markdown andcontext=[research_task, profile_task, resume_strategy_task]to develop interview materials
How does
contextwork inTasks?
- You can pass a list of tasks as
contextto 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_outputdefined in theTaskorbackstoryprovided in theAgentor 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_tokensinresult.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=Truewas enabled for two tasks, it’s throwing an error. How to fix it?
- When