Skip to main content
The society module simulates agent social behaviors and collaborative workflows.
It powers autonomous, multi-role agents that can plan, debate, critique, and solve tasks together, minimizing human intervention while maximizing alignment with your goals.

Society Concepts: How Do AI Agents Interact?

Task: An objective or idea, given as a simple prompt.
AI User: The role responsible for providing instructions or challenges.
AI Assistant: The role tasked with generating solutions, plans, or step-by-step responses.
Critic (optional): An agent that reviews or critiques the assistant’s responses for quality control.

RolePlaying

Turn-based, prompt-engineered, zero-role-flip agent collaboration.
  • Guards against role-flipping, infinite loops, vague responses
  • Structured, strict turn-taking—user and assistant never switch
  • Supports optional task planners, critics, and meta-reasoning
  • Every message follows a system-enforced structure
Built-in Prompt Rules:
  • Never forget you are <ASSISTANT_ROLE>, I am <USER_ROLE>
  • Never flip roles or instruct me
  • Decline impossible or unsafe requests, explain why
  • Always answer as: Solution: <YOUR_SOLUTION>
  • Always end with: Next request.

🧩 RolePlaying Attributes

AttributeTypeDescription
assistant_role_namestrName of assistant’s role
user_role_namestrName of user’s role
critic_role_namestrName of critic’s role (optional)
task_promptstrPrompt for the main task
with_task_specifyboolEnable task specification agent
with_task_plannerboolEnable task planner agent
with_critic_in_the_loopboolInclude critic in conversation loop
critic_criteriastrHow the critic scores/evaluates outputs
modelBaseModelBackendModel backend for responses
task_typeTaskTypeType/category of the task
assistant_agent_kwargsDictExtra options for assistant agent
user_agent_kwargsDictExtra options for user agent
task_specify_agent_kwargsDictExtra options for task specify agent
task_planner_agent_kwargsDictExtra options for task planner agent
critic_kwargsDictExtra options for critic agent
sys_msg_generator_kwargsDictOptions for system message generator
extend_sys_msg_meta_dictsList[Dict]Extra metadata for system messages
extend_task_specify_meta_dictDictExtra metadata for task specification
output_languagestrTarget output language
assistant_agentChatAgentCustom ChatAgent to use as assistant (optional)
user_agentChatAgentCustom ChatAgent to use as user (optional)

Get Started: RolePlaying in Action

Example: Turn-based multi-agent chat with custom roles and live output colors.

  • Use RolePlaying for most multi-agent conversations, with or without a critic.
  • Define specific roles and prompt-guardrails for your agents—structure is everything!
  • Try BabyAGI when you want open-ended, research-oriented, or autonomous projects.
  • Leverage the with_task_specify and with_task_planner options for highly complex tasks.
  • Monitor for infinite loops—every agent response should have a clear next step or end.
  • Check examples/society/ in the CAMEL repo for advanced agent society demos.
  • Explore critic-in-the-loop setups for higher accuracy and safety.
  • Integrate toolkits or external APIs into agent society loops for real-world workflows.