A Comprehensive Guide to Collaborative AI Agents in Practice

Author:Murphy  |  View: 28181  |  Time: 2025-03-22 20:59:49
Image created by DALLE3.

Not a member? Read for free!

Agentic AI is one of the hottest subjects of the AI community in 2024 and there is a good reason for that. Foundational Models are becoming more sophisticated in reasoning and planning. With these capabilities in place, we can leverage LLMs to divide a given task into smaller pieces, perform them step by step, and reflect on their results, essentially creating AI Agents.

If you're passionate about AI, or you like playing with Language Models, or you're working in Machine Learning, a comprehensive understanding of AI agents and how they look in action is necessary if you want to keep up with the latest AI achievements.

If you're in the job search process as I am, you know that writing a cover letter for each job you apply to or adjusting the CV to pinpoint job requirements is a tedious step. For my implementation of AI agents, I will develop a team of AI agents that collaborate to:

  • Extract the key information out of a job description
  • Modify your CV and Cover Letter to address the job
  • Evaluate the final result from a recruiter's point of view, and give you a score from 0 to 100
Fig 1. We will create a team of AI agents to modify our CV and Cover Letter and give us a score from 0 to 100. (by Author)

In this article, we will walk through what collaborative AI agents are, what makes agents different from LLMs, and go through a practical implementation to showcase how creating AI agents might be much simpler than you would expect.

· AI Agent Made SimpleLLM-Powered AI Agents · Multi-Agent CollaborationWhat Makes an AgentWhat We Need With Multi-Agents · Code Implementation: Agents that Help You Apply For Jobs

AI Agent Made Simple

AI agent is a goal-oriented tool crafted to accomplish a specific set of tasks. While AI language models are created to generate responses for specific prompts, AI agents operate on a broader scale by addressing complex problems through decision-making and task execution. They reason upon a mission, and by using their available tools, execute smaller agendas to finish the task.

AI chatbots speak, AI agents act.

Whether in customer service, finance, or software development, AI agents are made for one thing: automation. The hope is that AI agents help individuals and organizations with their mundane routines, with lower costs to solving less creative agendas.

Fig 2. The outline of how a model LLM-based agent is structured. (Source: Wikimedia)

LLM-Powered AI Agents

Even though AI Agents are very different from Large Language Models, LLMs are the brains of our AI agents. Agents need LLMs to do anything intelligently, reason, and plan their next steps. This means that which LLM you use, changes the behavior of the agent completely. This is why the rise of AI agents topic was made possible by the surge of Gen-AI.

Note: The AI agents we hear about today have a somewhat different meaning than the traditional literature and textbooks. This can get confusing if you're simply searching about AI agents, and you get diverse definitions of what they are. The AI agents we use today, and are the trending topic of the AI community, are LLM-based agents that we are discussing in this article.

Fig 3. (by Author)

At their core, autonomous AI agents benefit from three components:

  1. Planning: This core function of an agent, allows it to break a goal into smaller steps and work on them one by one. Another aspect of their planning is to self-reflect on their actions and learn from them. The way an agent pulls off self-reflection very much depends on the implementation, but a general outline could be thought of as displayed in Figure 4.
  2. Memory: To learn from past mistakes, you must remember them. Memory is the component of storing, and later retrieving information by the agent, to refine its actions.
  3. Tool Use: A key differentiating factor between a simple Llm and an AI agent, is their ability to use tools. Using tools can be as simple as calling an API, or using a Python function to read or write some files.
Fig 4. Self-reflection is a finite loop between the agent thinking what to do, acting on it, and observing the results, potentially taking a new approach to the problem. (by Author)

Multi-Agent Collaboration

What is better than a single agent? Many of them!

Having one AI agent is one thing, but having multiple AI agents that collaborate with each other to chop up tasks and act on them is another story.

But why do we NEED multiple agents?

When breaking a goal down into smaller parts, you end up with sub-goals that require different sets of skills. That's where you need multiple agents. A team of agents, with each one of them having a specific role and skillset, ensures that each sub-goal is tackled by its own agent.

You might even need to power each agent with a different LLM that is more sophisticated for the task to which that agent is assigned. An agent created for programming capabilities might need a completely different LLM than an agent who is supposed to write articles.

What Makes an Agent

How you would define an agent very much depends on the implementation or the library you use. In general, an agent boils down to three main elements:

Fig 5. (by Author)
  1. Goal: The specific objective the agent aims to accomplish. This shapes its decision-making framework. For example, "write easy-to-understand object-oriented Python code."
  2. Role: The function of an agent. Who is it? A debugger, data scientist, sales marketer, etc.
  3. Backstory: The context of the agent. Explains the goal, role, and what the agent is good at. An example of a backstory could be, "You are a senior Python programmer with a specialization in writing optimized, well-documented code and its test cases."

What We Need With Multi-Agents

The implementation details of multi-agent have some nuances to consider. Imagine a team of people working towards the same goal, a team of chefs in a restaurant kitchen as an example.

Image created by DALLE3.

You would need a head chef who leads the team. The team members need to communicate with each other. You need them to be able to send their finished work to the other chefs for the next step of the food preparation. This is just an example of how many things are needed to make multiple agents collaborate toward a shared assignment.

Generally, with multiple agents, you would need:

  1. Sharing Information: Agents need to pass their results to each other and share their findings. An agent's finished work might be the input of another agent to start their task.
  2. Collaboration: Agents should be able to use each other's help and delegate parts of their work if needed. This might not be a must in simple scenarios, but in complex processes, it is pretty necessary.
  3. Manager Agent: Controls the flow of tasks between the agents, keeping them in control.

Code Implementation: Agents that Help You Apply For Jobs

Now let's create our team of agents. There are multiple libraries that enable you to develop AI agents, such as LlamaIndex or LangChain. I will use CrewAI for its easy-to-use workflow and high level of abstraction. It's free to use and while giving you adequate control over your agents, saves you from unnecessary complexity in simple projects.

I will create a team of agents to help me modify my CV and Cover Letter for a given job description to evaluate the final result and see how much I will have the chance of getting an interview. For this purpose, I will create four agents:

  1. Job Crawler: This agent will receive the URL of the job posting, crawl the webpage, and extract the key information about the job requirements, qualifications, etc.
  2. CV Modifier: Based on the key information about the job, provided by Job Crawler, this agent reads my CV and enhances it to better fit the job description.
  3. Cover Letter Modifier: This works the same as CV Modifier, but works on my cover letter instead.
  4. Recruiter: Acts as the job recruiter and analyzes my modified CV and cover letter. It will give me feedback and also a score in the range [0–100].
Fig 6. Outline of the agent workflow. (by Author)

For the LLM, we will use gpt-4-turbo . However, using Ollama, you can run LLMs 100% locally and free. I will not go into details in this article, but to know how you can run LLama-3, Mistral, Phi-3, and many more models locally on your machine, read this article:

Tags: Ai Agent Hands On Tutorials Large Language Models Llm Machine Learning

Comment