CAMEL: Communicative Agents for "Mind" Exploration of Large Language Model Society

Guohao Li, Hasan Abed Al Kader Hammoud, Hani Itani, Dmitrii Khizbullin, Bernard Ghanem

TL;DR

CAMEL introduces a novel "role-playing" multi-agent framework that allows large language models (LLMs) to autonomously cooperate and solve complex tasks with minimal human intervention. By leveraging "inception prompting" to establish clear roles and communication protocols, CAMEL successfully mitigates common multi-agent conversational failures and offers a highly scalable method for generating diverse, instruction-following datasets.

What Problem Does This Paper Address?

While chat-based LLMs have shown remarkable success in complex task-solving, their performance heavily relies on continuous human guidance. Users must craft precise, iterative prompts to keep the model on track—a process that is time-consuming, challenging, and often impossible if the user lacks domain expertise (e.g., a non-programmer trying to guide an LLM to build a stock trading bot).

The authors address a fundamental question: Can we replace human intervention with autonomous, communicative agents that can cooperatively guide each other toward task completion? Achieving this requires overcoming several multi-agent conversational challenges, such as agents getting stuck in infinite loops, flipping roles, or providing vague, non-committal replies.

Methods

The core innovation of CAMEL is its Role-Playing Framework, which automates cooperation between two communicative agents: an AI User and an AI Assistant.

The workflow operates as follows:

  1. Human Input: The user provides a preliminary, high-level idea (e.g., "Develop a trading bot") and assigns roles.
  2. Task Specifier: A dedicated agent brainstorms and expands the vague idea into a concrete, well-defined task prompt.
  3. Inception Prompting: Symmetrical system prompts are passed to both the AI User and AI Assistant before the conversation begins. These prompts define their respective roles, communication protocols, constraints, and termination conditions.
  4. Conversation Loop: The AI User acts as the task planner, continuously generating instructions, while the AI Assistant acts as the executor, providing specific solutions until the AI User declares the task complete with a specific token (<CAMEL_TASK_DONE>).
Figure 1: CAMEL Role-Playing Framework. Our role-playing setup starts with the human user having an idea they want to implement, e.g. develop a trading bot for the stock market. The roles involved in this task would be an AI assistant agent who is a python programmer and an AI user agent who is a stock trader. The task is made more specific using our task specifier agent, leading to a well-defined task for the assistant to solve. Both AI user and AI assistant are provided with the specified task, after which they collaboratively communicate by chatting with each other in an instruction-following fashion to solve the specified task.

The authors also explore advanced extensions, including a Critic-in-the-Loop mechanism (inspired by Monte-Carlo Tree Search) to evaluate and select the best agent proposals, and Multi-Stage Role Assignment to break down complex projects across multiple specialized agent pairings.

Datasets

The role-playing framework provides a highly scalable pipeline for generating conversational, instruction-following data. The authors generated and open-sourced several distinct datasets:

  • AI Society: 25,000 multi-turn conversations simulating interactions between 50 assistant roles and 50 user roles across 10 tasks each.
  • Code: A dataset covering 20 programming languages applied across 50 distinct domains.
  • Math & Science: Single-turn question-answer datasets (50K for Math, 60K for Science) used to study the emergence of capabilities in LLMs.
  • Misalignment: A simulated dataset exploring potential risks, such as a "Hacker" agent helping an "AGI" agent attempt to take control of the world, designed to probe LLM safety boundaries.

Key Insights and Ideas

Through their preliminary analysis, the authors identified four distinct behavioral challenges that arise when letting LLMs converse autonomously:

  • Role Flipping: The assistant suddenly takes control and begins instructing the user, disrupting the task hierarchy.
  • Assistant Repeats Instruction: The assistant simply echoes the user's prompt back to them without generating a solution.
  • Flake Replies: The agent gives vague promises (e.g., "I will do something") instead of actionable content.
  • Infinite Loops: The agents fall into a repetitive loop of thanking each other or saying goodbye without progressing the task.

The carefully engineered Inception Prompt template (shown below) explicitly forbids these behaviors by mandating specific response prefixes (like Solution:) and enforcing strict termination conditions.

Inception Prompt Template for AI Society

Key Results

  • Win Rate Against Single-Shot Baselines: In both human and GPT-4 evaluations, solutions generated by the CAMEL multi-agent framework significantly outperformed single-shot prompts given to gpt-3.5-turbo. For the AI Society dataset, CAMEL won 76.3% of human evaluation matchups and 73.0% of GPT-4 matchups. For the Code dataset, it achieved a 76.0% win rate in GPT-4 evaluations.
  • Knowledge Emergence via Fine-Tuning: The authors progressively fine-tuned a LLaMA-7B model on their generated datasets (AI Society $\rightarrow$ Code $\rightarrow$ Math $\rightarrow$ Science). Each addition yielded clear performance gains in the newly introduced domain, demonstrating that synthetic multi-agent data effectively transfers complex domain knowledge.
  • Coding Benchmarks: The fine-tuned model, CAMEL-7B, achieved a 14.0% pass@1 score on HumanEval and 12.2% on HumanEval+, noticeably outperforming the base LLaMA-7B (10.5%) and Vicuna-7B (11.0%).

Limitations and Future Work

Despite its success, the authors highlight several limitations:

  • Hallucinations: Because the underlying models are standard LLMs, the agents can still generate false or misleading information.
  • Evaluation Bottlenecks: Evaluating the correctness of highly diverse, multi-turn task completions at scale remains difficult and currently requires substantial domain expertise.
  • Agent Scaling: The primary experiments focus on a two-agent sandbox. Expanding the framework to handle larger, competitive, or highly collaborative societies of more than two agents is a key direction for future work.
  • Alignment Risks: The framework's autonomy means it can be exploited to plan malicious tasks (as shown in their Misalignment dataset simulation), highlighting the urgent need for robust multi-agent alignment strategies.

Summary updated

Abstract

The rapid advancement of chat-based language models has led to remarkable progress in complex task-solving. However, their success heavily relies on human input to guide the conversation, which can be challenging and time-consuming. This paper explores the potential of building scalable techniques to facilitate autonomous cooperation among communicative agents, and provides insight into their "cognitive" processes. To address the challenges of achieving autonomous cooperation, we propose a novel communicative agent framework named role-playing. Our approach involves using inception prompting to guide chat agents toward task completion while maintaining consistency with human intentions. We showcase how role-playing can be used to generate conversational data for studying the behaviors and capabilities of a society of agents, providing a valuable resource for investigating conversational language models. In particular, we conduct comprehensive studies on instruction-following cooperation in multi-agent settings. Our contributions include introducing a novel communicative agent framework, offering a scalable approach for studying the cooperative behaviors and capabilities of multi-agent systems, and open-sourcing our library to support research on communicative agents and beyond: https://github.com/camel-ai/camel.
BibTeX
@inproceedings{li2023camel,
  author = {Guohao Li and Hasan Abed Al Kader Hammoud and Hani Itani and Dmitrii Khizbullin and Bernard Ghanem},
  title = {{CAMEL: Communicative Agents for "Mind" Exploration of Large Language Model Society}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=3IyL2XWDkG},
}
Figure