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.
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.
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
All RolePlaying Parameters
All RolePlaying Parameters
| Attribute | Type | Description |
|---|---|---|
| assistant_role_name | str | Name of assistant’s role |
| user_role_name | str | Name of user’s role |
| critic_role_name | str | Name of critic’s role (optional) |
| task_prompt | str | Prompt for the main task |
| with_task_specify | bool | Enable task specification agent |
| with_task_planner | bool | Enable task planner agent |
| with_critic_in_the_loop | bool | Include critic in conversation loop |
| critic_criteria | str | How the critic scores/evaluates outputs |
| model | BaseModelBackend | Model backend for responses |
| task_type | TaskType | Type/category of the task |
| assistant_agent_kwargs | Dict | Extra options for assistant agent |
| user_agent_kwargs | Dict | Extra options for user agent |
| task_specify_agent_kwargs | Dict | Extra options for task specify agent |
| task_planner_agent_kwargs | Dict | Extra options for task planner agent |
| critic_kwargs | Dict | Extra options for critic agent |
| sys_msg_generator_kwargs | Dict | Options for system message generator |
| extend_sys_msg_meta_dicts | List[Dict] | Extra metadata for system messages |
| extend_task_specify_meta_dict | Dict | Extra metadata for task specification |
| output_language | str | Target output language |
Get Started: RolePlaying in Action
Example: Turn-based multi-agent chat with custom roles and live output colors.
Tips & Best Practices
Tips & Best Practices
- 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_specifyandwith_task_planneroptions for highly complex tasks. - Monitor for infinite loops—every agent response should have a clear next step or end.
More Examples & Advanced Use
More Examples & Advanced Use
- 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.