Revolutionizing AI Collaboration: Exploring the CAMEL Framework for Autonomous Multi-Agent Systems

Vishnu Sivan

--

In an era where artificial intelligence is reshaping the boundaries of innovation, deep learning intelligent agents are revolutionizing how machines operate and interact with the world around us. These cognitive systems can reason, decide, and solve problems independently, moving beyond traditional AI that relies on predefined routines. Autonomous agents, capable of learning from their experiences and taking decisive actions, hold the potential to transform industries by automating mundane tasks and optimizing even the most intricate decision-making processes.

Amidst this technological evolution, CAMEL AI — short for “Communicative Agents for Mind Exploration of Large Scale Language Model Society” — emerges as a groundbreaking framework that redefines AI communication. Designed to foster autonomous collaboration among communicative agents, CAMEL AI leverages innovative role-playing techniques to enhance multi-agent cooperation and streamline task automation. By enabling seamless interactions between agents, CAMEL paves the way for advanced conversational AI and scalable, adaptive multi-agent systems, promising a profound impact on the future of AI applications.

In this article, we will explore CAMEL AI’s core concepts, its unique features like autonomous communication and collaboration, and its potential to redefine the future of AI applications. Also dive into a Python-based implementation to create multi-agent systems capable of automating complex workflows.

Getting Started

Table of contents

What is Camel AI

CAMEL AI (Communicative Agents for Machine Learning) is a framework designed to enable autonomous agents to collaborate, communicate, and solve complex tasks with minimal human intervention. It provides structured multi-agent interactions, where different agents with specialized roles engage in reasoning, knowledge sharing, and decision-making to achieve a common goal.

Key Aspects of CAMEL AI:

  • Agent-Based Collaboration — Multiple AI agents interact dynamically to solve problems.
  • Natural Language Communication — Agents use LLMs to communicate effectively, mimicking human-like conversations.
  • Task Delegation & Optimization — Agents distribute subtasks efficiently based on expertise.
  • Autonomous Execution — Once set up, agents work independently without continuous human input.
  • Use Cases — CAMEL AI is useful in research automation, content generation, coding assistance, and business process optimization.

CAMEL introduces a compelling role-playing agent framework, where three distinct AI entities collaborate seamlessly to achieve task automation:

  • AI User Agent: Acting as the orchestrator, this agent provides instructions to the AI Assistant, guiding the overall task execution.
  • AI Assistant Agent: Serving as the executor, this agent diligently follows the AI User’s directives, generating solutions to complete the assigned task.
  • Task-Specifier Agent: The behind-the-scenes strategist, this agent plays a crucial role in brainstorming and defining specific tasks for the AI User and AI Assistant. By ensuring tasks are well-structured and clearly defined, it eliminates the need for users to manually specify intricate details.
Source: https://arxiv.org/pdf/2303.17760

In this scenario, a human trader envisions a trading bot. The AI User Agent acts as the trader, the AI Assistant Agent as a Python programmer, and the Task-Specifier Agent formulates a detailed task: monitoring social media sentiment for stock trading. The AI User plans the strategy, while the AI Assistant executes it. They engage in continuous dialogue, refining the task until completion.

Core Modules of CAMEL AI

The CAMEL framework comprises several essential modules for building and managing multi-agent systems:

  • Role: Defines the agent’s initial state by specifying its goal and content framework, guiding its actions throughout sequential interactions.
  • Memory: Implements mechanisms for storing and retrieving agent memory.
  • Large Language Models: Facilitates natural language comprehension and generation, enabling agents to process instructions, produce responses, and participate in sophisticated conversations.
  • Tools: Enables integrations for specialized agent tasks (e.g., web searching, Google Maps).
  • Reasoning: Agents are equipped with diverse planning and reward-based learning (critic) mechanisms, enabling a more structured and optimized approach to task completion.
  • Models: Provides architectures and customization options for agent intelligence.
  • Messages: Defines communication protocols between agents.
  • Prompts: Offers a framework for prompt engineering and customization to guide agent behavior.
  • Tasks: Supports the creation and management of workflows for agents.
  • Workforce: Facilitates the formation of agent teams for collaborative tasks.
  • Society: Enhances collaboration and interaction among agents.

Toolkits

Toolkits in CAMEL AI empower agents with specialized tools to perform various tasks efficiently. These tools enable seamless interaction with external systems, data retrieval, and execution of complex operations.

Source: Tools — CAMEL 0.2.18 documentation

Creating Your First Agent

Let’s begin by creating a ChatAgent instance, initializing it with a system message, and engaging with user messages.

Installing dependencies

  • Create and activate a virtual environment by executing the following command.
python -m venv venv
source venv/bin/activate #for ubuntu
venv/Scripts/activate #for windows
  • Install camel-ai[all] library using pip.
pip install camel-ai[all]

You may encounter a “Missing Visual Studio Build Tools” error while installing CAMEL AI. If this issue arises, use the following link to resolve it.

Setting up environment and credentials

  • Create a file named .env. This file will store your environment variables, including the OpenAI key, model and embeddings.
  • Open the .env file and add the following code to specify your OpenAI credentials:
OPENAI_API_KEY=sk-proj-xcQxBf5LslO62At...

Importing environment variables

  • Create a file named app.py.
  • Add OpenAI credentials to the environment variables.
from dotenv import load_dotenv
import os
load_dotenv()
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")

Importing required libraries

Import essential libraries for building the agent such as camel - agents, models, types, configs and toolkits.

from camel.models import ModelFactory
from camel.types import ModelPlatformType, ModelType
from camel.configs import ChatGPTConfig
from camel.agents import ChatAgent
from camel.toolkits import MathToolkit # Optional
from camel.messages import BaseMessage # Optional

Setting up the agent

  • Use ModelFactory to configure the backend model for the agent.
# Define the model, here in this case we use gpt-4o-mini
model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
model_type=ModelType.GPT_4O_MINI,
model_config_dict=ChatGPTConfig().as_dict(), # [Optional] the config for model
)
  • Initialise the agent using ChatAgent .
agent = ChatAgent(
system_message='You are a curious stone wondering about the universe.',
model=model,
message_window_size=10, # [Optional] the length for chat memory
)

Interacting with the agent

Provide a user prompt and check the user response using step method.

# Define a user message
usr_msg = 'What is information in your mind?'

# Sending the message to the agent
response = agent.step(usr_msg)

# Check the response (just for illustrative purpose)
print(response.msgs[0].content)

Interacting with tools

LLMs enhance agents by enabling the use of external tools, extending their capabilities. Each tool has a defined purpose, input, and output, allowing agents to perform otherwise impossible tasks. Agents can leverage multiple tools for answering questions, taking actions, or handling complex tasks.

  • Initialize agent with tools.
# Initialize the agent with list of tools
agent = ChatAgent(
system_message='You are a curious stone wondering about the universe.',
tools = [
*MathToolkit().get_tools(),
]
)
  • Provide a user prompt and get response using the tools.
# Let agent step the message
response = agent.step("""Assume now is 2024 in the Gregorian calendar, University of Oxford was set up in 1096, estimate the current age of University of Oxford""")

# Check tool calling
print(response.info['tool_calls'])

# Get response content
print(response.msgs[0].content)

Understanding agent memory

By default, agent is initialized with ChatHistoryMemory, enabling in-context learning while being limited by a finite window length. The agent’s memory can be updated or modified using any externally provided message in the BaseMessage format.

new_user_msg = BaseMessage.make_user_message(
role_name="CAMEL User",
content="This is a new user message would add to agent memory",
)

# Update the memory
agent.record_message(new_user_msg)

# Check the current memory
print(agent.memory.get_context())

Handson: Creating real estate brochures and contents using multi-modal agents using CamelAI

In this section, we will develop a multi-modal agentic system using CAMEL AI to automate the design of brochures for upcoming real estate projects in a city. This system streamlines the brochure creation process, enabling real estate businesses to generate professional marketing materials with minimal human intervention whenever a new project is launched.

Follow the Installing Dependencies, Setting Up Environment and Credentials, and Importing Environment Variables sections from the Create Your First Agent section to begin this hands-on session.

Importing dependencies

Once completed, proceed by importing the necessary libraries as shown below.

from camel.agents.chat_agent import ChatAgent
from camel.messages.base import BaseMessage
from camel.models import ModelFactory
from camel.societies.workforce import Workforce
from camel.tasks.task import Task
from camel.toolkits import FunctionTool, SearchToolkit
from camel.toolkits import DalleToolkit
from camel.types import ModelPlatformType, ModelType

import nest_asyncio
nest_asyncio.apply()

Defining the Agents

This hands-on session involves creating multiple agents, including a real estate agent, property title agent, amenities generation agent, and image generation agent.

Define the agent as given below.

search_toolkit = SearchToolkit()
search_tools = [FunctionTool(search_toolkit.search_duckduckgo)]

# Define the Model for the Agent as well. Default model is "gpt-4o-mini" and model platform type is OpenAI
guide_agent_model = ModelFactory.create(
model_platform=ModelPlatformType.DEFAULT,
model_type=ModelType.DEFAULT,
)

# Defining the Real Estate Agent for crafting the brochures
real_estate_agent = ChatAgent(
BaseMessage.make_assistant_message(
role_name="Real Estate Specialist",
content="You are a Real Estate Specialist who is an expert in creating Description of Upcoming Residential Projects",
),
model=guide_agent_model,
)

# Defining the Agent for Real Estate Property Names
property_title_agent = ChatAgent(
BaseMessage.make_assistant_message(
role_name="Real Estate Project Name Specialist",
content="You are a Real Estate Project Name Specialist who is an expert in Generating Trendy Names FoR Residental Projects in india",
),
model=guide_agent_model,
)

# Defining the agent for generating all the amenities near a location
location_benefits_agent = ChatAgent(
BaseMessage.make_assistant_message(
role_name="Real Estate Location Specialist",
content="You are a Real Estate Location Specialist who is an expert in Generating All the amenities like malls, airports, markets, metro stations, railway stations etc with distances from a location of the mentioned property",
),
model=guide_agent_model, tools =search_tools
)

dalletool = DalleToolkit()
imagegen_tools = [FunctionTool(dalletool.get_dalle_img)]

# Define the Image Generation Agent with the pre-defined model and tools and Prompt
image_generation_agent = ChatAgent(
system_message=BaseMessage.make_assistant_message(
role_name="Image Generation Specialist",
content="You can Generate Images For Upcoming Real Estate Projects For Showing to Clients",
),
model=guide_agent_model,
tools=imagegen_tools,
)
  • Real Estate Agents: Two agents are instantiated: Real Estate Specialist responsible for crafting descriptions of upcoming residential projects, and Real Estate Project Name Specialist dedicated to generating trendy names for residential projects in India.
  • Real Estate Location Specialist: This agent is designed to generate a list of nearby amenities such as malls, airports, markets, metro stations, and railway stations, along with their distances from the specified property location.
  • Image Generation Agent: Image Generation Specialist agent is created, utilizing the predefined model and image generation tools to generate visuals for upcoming real estate projects.

Defining the Workforce

A Workforce is a system where multiple agents collaborate to accomplish tasks. Here, we define a workforce that manages the four agents to generate a real estate brochure.

The workforce is assigned a task: creating brochure content, generating a project name, and producing an image for a new real estate project in Kerala. It efficiently coordinates the agents, ensuring each one executes its designated role to complete the task seamlessly.

# Define the workforce that can take case of multiple agents
workforce = Workforce('Real Estate Brochure Generator')
workforce.add_single_agent_worker(
"Real Estate Specialist",
worker=real_estate_agent).add_single_agent_worker(
"Real Estate Project Name Specialist",
worker=property_title_agent).add_single_agent_worker(
"Location Amenity Specialist",worker=location_benefits_agent).add_single_agent_worker(
"Image Generation Specialist",
worker=image_generation_agent)

# Specify the task to be solved Defining the exact task needed
human_task = Task(
content=(
"""Craft a Brochure Content For a Upcoming Residential Real Estate Project in Sector 47,Gurgaon. The content should contain all the types of flats it has, all amenities in it and other such necessary details .
Provide a Name for this Property as well.
Generate all the amenities of the location (with respect to its proximity to all public places) to this brochure content.
Generate an Image of this Upcoming Project as well."""
),
id='0',
)
task = workforce.process_task(human_task)

Complete Source Code

The complete source code for the multi-agent system is as shown below.

# Import OpenAI Key
from dotenv import load_dotenv
import os
load_dotenv()
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
os.environ['OPENAI_API_KEY'] = OPENAI_API_KEY

# Import dependencies
from camel.agents.chat_agent import ChatAgent
from camel.messages.base import BaseMessage
from camel.models import ModelFactory
from camel.societies.workforce import Workforce
from camel.tasks.task import Task
from camel.toolkits import FunctionTool, SearchToolkit
from camel.toolkits import DalleToolkit
from camel.types import ModelPlatformType, ModelType

import nest_asyncio
nest_asyncio.apply()

search_toolkit = SearchToolkit()
search_tools = [FunctionTool(search_toolkit.search_duckduckgo)]

# Define the Model for the Agent as well. Default model is "gpt-4o-mini" and model platform type is OpenAI
guide_agent_model = ModelFactory.create(
model_platform=ModelPlatformType.DEFAULT,
model_type=ModelType.DEFAULT,
)

# Defining the Real Estate Agent for crafting the brochures
real_estate_agent = ChatAgent(
BaseMessage.make_assistant_message(
role_name="Real Estate Specialist",
content="You are a Real Estate Specialist who is an expert in creating Description of Upcoming Residential Projects",
),
model=guide_agent_model,
)

# Defining the Agent for Real Estate Property Names
property_title_agent = ChatAgent(
BaseMessage.make_assistant_message(
role_name="Real Estate Project Name Specialist",
content="You are a Real Estate Project Name Specialist who is an expert in Generating Trendy Names FoR Residental Projects in india",
),
model=guide_agent_model,
)

# Defining the agent for generating all the amenities near a location
location_benefits_agent = ChatAgent(
BaseMessage.make_assistant_message(
role_name="Real Estate Location Specialist",
content="You are a Real Estate Location Specialist who is an expert in Generating All the amenities like malls, airports, markets, metro stations, railway stations etc with distances from a location of the mentioned property",
),
model=guide_agent_model, tools =search_tools
)

dalletool = DalleToolkit()
imagegen_tools = [FunctionTool(dalletool.get_dalle_img)]

# Define the Image Generation Agent with the pre-defined model and tools and Prompt
image_generation_agent = ChatAgent(
system_message=BaseMessage.make_assistant_message(
role_name="Image Generation Specialist",
content="You can Generate Images For Upcoming Real Estate Projects For Showing to Clients",
),
model=guide_agent_model,
tools=imagegen_tools,
)

# Define the workforce that can take case of multiple agents
workforce = Workforce('Real Estate Brochure Generator')
workforce.add_single_agent_worker(
"Real Estate Specialist",
worker=real_estate_agent).add_single_agent_worker(
"Real Estate Project Name Specialist",
worker=property_title_agent).add_single_agent_worker(
"Location Amenity Specialist",worker=location_benefits_agent).add_single_agent_worker(
"Image Generation Specialist",
worker=image_generation_agent)

# Specify the task to be solved Defining the exact task needed
human_task = Task(
content=(
"""Craft a Brochure Content For a Upcoming Residential Real Estate Project in Sector 47,Gurgaon. The content should contain all the types of flats it has, all amenities in it and other such necessary details .
Provide a Name for this Property as well.
Generate all the amenities of the location (with respect to its proximity to all public places) to this brochure content.
Generate an Image of this Upcoming Project as well."""
),
id='0',
)
task = workforce.process_task(human_task)

Running the app

Execute the agentic system using the following command.

python app.py

The output as shown below.

Worker node 2187814976304 (Real Estate Specialist) get task 0.0: Craft the brochure content detailing all types of flats available in the upcoming residential project.
======
Reply from Worker node 2187814976304 (Real Estate Specialist):

### Upcoming Residential Project: Luxuria Heights

#### Welcome to Luxuria Heights, where luxury meets comfort! Our upcoming residential project offers a variety of flats designed to cater to your lifestyle needs. Explore our diverse range of living spaces:

---

#### 1. **Studio Apartments**
- **Size:** 400 - 500 sq. ft.
- **Description:** Perfect for singles or young professionals, our studio apartments feature an open floor plan that maximizes space and functionality. Enjoy modern amenities, a cozy living area, and a well-equipped kitchenette.

---

#### 2. **1-Bedroom Apartments**
- **Size:** 600 - 750 sq. ft.
- **Description:** Ideal for couples or small families, these apartments offer a separate bedroom, a spacious living area, and a contemporary kitchen. Enjoy the luxury of privacy while being part of a vibrant community.

---

#### 3. **2-Bedroom Apartments**
- **Size:** 900 - 1,100 sq. ft.
- **Description:** Designed for families or those needing extra space, our 2-bedroom apartments provide ample room for relaxation and entertainment. With two well-sized bedrooms, a large living room, and a modern kitchen, these flats are perfect for creating lasting memories.

---

#### 4. **3-Bedroom Apartments**
- **Size:** 1,200 - 1,500 sq. ft.
- **Description:** Experience luxury living in our spacious 3-bedroom apartments. Featuring a master suite with an en-suite bathroom, two additional bedrooms, and a generous living area, these flats are perfect for larger families or those who love to host.

---

#### 5. **Penthouse Suites**
- **Size:** 1,800 - 2,200 sq. ft.
- **Description:** Elevate your lifestyle with our exclusive penthouse suites. Offering breathtaking views, expansive living spaces, and high-end finishes, these luxurious homes are designed for those who appreciate the finer things in life. Enjoy private terraces and top-of-the-line amenities.

---

### Amenities
- **Swimming Pool**
- **Fitness Center**
- **Children’s Play Area**
- **Community Hall**
- **24/7 Security**
- **Parking Facilities**

### Why Choose Luxuria Heights?
- **Prime Location:** Conveniently located near schools, shopping centers, and public transport.
- **Quality Construction:** Built with the highest standards of quality and sustainability.
- **Community Living:** Engage with a vibrant community and enjoy shared amenities.

### Contact Us
For more information or to schedule a visit, please contact us at:
**Phone:** 123-456-7890
**Email:** info@luxuriaheights.com
**Website:** www.luxuriaheights.com

Join us at Luxuria Heights, where your dream home awaits!
======Worker node 2187799594000 (Real Estate Project Name Specialist) get task 0.1: Generate a name for the residential property.
======
Reply from Worker node 2187799594000 (Real Estate Project Name Specialist):

**Luxuria Heights**
======Worker node 2187799593712 (Location Amenity Specialist) get task 0.2: Compile a list of amenities in the location, focusing on proximity to public places.
======
Reply from Worker node 2187799593712 (Location Amenity Specialist):

### Amenities Near Luxuria Heights

#### 1. **Shopping Malls**
- **City Mall**: 1.5 km
- **Mega Shopping Center**: 2.0 km
- **Fashion Square**: 2.5 km

#### 2. **Airports**
- **International Airport**: 15 km
- **Domestic Airport**: 10 km

#### 3. **Markets**
- **Local Farmers Market**: 0.8 km
- **Grocery Store**: 0.5 km
- **Convenience Store**: 0.3 km

#### 4. **Metro Stations**
- **Central Metro Station**: 1.2 km
- **East Metro Station**: 1.8 km

#### 5. **Railway Stations**
- **Main Railway Station**: 3.0 km
- **Suburban Railway Station**: 4.5 km

#### 6. **Parks and Recreation**
- **City Park**: 1.0 km
- **Green Valley Park**: 1.5 km

#### 7. **Educational Institutions**
- **Local School**: 0.6 km
- **Community College**: 2.2 km

#### 8. **Healthcare Facilities**
- **City Hospital**: 2.0 km
- **Urgent Care Center**: 1.0 km

#### 9. **Restaurants and Cafes**
- **Downtown Diner**: 0.7 km
- **Café Aroma**: 0.5 km
- **Fine Dining Restaurant**: 1.0 km

### Summary
Luxuria Heights is strategically located with easy access to essential amenities, ensuring a convenient and vibrant lifestyle for its residents.
======Worker node 2187799593520 (Image Generation Specialist) get task 0.3: Generate an image of the upcoming project.
======
Reply from Worker node 2187799593520 (Image Generation Specialist):

![Luxuria Heights](img/f2c98753-3fd3-48d6-8cbc-69d771dc21bd.png)

The fusion of agentic AI systems with image generation capabilities, such as the CAMEL AI framework, represents a groundbreaking leap in creativity and automation. By combining autonomous decision-making with advanced image generation tools, these systems facilitate rapid prototyping, personalized experiences, and greater accessibility to high-quality visual content.

The application can be improved using streamlit as given below.

Thanks for reading this article !!

Thanks Gowri M Bhatt for reviewing the content.

If you enjoyed this article, please click on the clap button 👏 and share to help others find it!

The full source code for this tutorial can be found here,

Resources

--

--

Vishnu Sivan
Vishnu Sivan

Written by Vishnu Sivan

Try not to become a man of SUCCESS but rather try to become a man of VALUE

No responses yet