Skip to main content

Overview

The LLMCouncil creates a council of specialized LLM agents that collaborate through independent responses, peer review, and synthesis. Inspired by Andrej Karpathy’s llm-council, it demonstrates how different models evaluate and rank each other’s work.

Installation

Workflow

  1. Dispatch: Task sent to all council members in parallel
  2. Respond: Each member independently answers the task
  3. Evaluate: Every member reviews and ranks all responses, which are relabelled Response A, Response B, and so on in a shuffled order. Evaluations run concurrently
  4. Synthesize: The Chairman receives every response under its member’s name, every evaluation, and the mapping from anonymous IDs to members, and writes the final answer
Each run starts from an empty conversation, so reusing a council for several tasks never mixes their transcripts.

Attributes

str
default:"generate_id('llm-council')"
Unique identifier for the council
str
default:"LLM Council"
Name of the council
str
default:"A collaborative council of LLM agents..."
Description of the council’s purpose
Optional[List[Agent]]
default:"None"
List of Agent instances representing council members. If None, creates the default council of four members on OpenAI, Gemini, Anthropic, and xAI models.
str
default:"gpt-5.1"
Model name for the Chairman agent that synthesizes responses. The Chairman runs with temperature=0.7.
bool
default:"True"
Whether to log one line per stage through loguru: initialization, collecting responses, ranking, synthesis, and completion.
HistoryOutputType
default:"dict-all-except-first"
Format for the output ("list", "dict", "string", "final", "json", "yaml", and so on). The default returns every message after the task as a list of message dicts. Use "final" for only the Chairman’s answer.

Methods

run()

Execute the full LLM Council workflow.
Parameters:
  • task (str): The user’s task to process. Required.
Returns: The conversation formatted according to output_type, containing the member responses, evaluations, and the Chairman’s synthesis Raises: ValueError if task is not a string, is empty, or contains only whitespace
The query alias was removed. Call run(task=...) or pass the task positionally.

batched_run()

Run the LLM Council workflow for a batch of tasks, one after another.
Parameters:
  • tasks (List[str]): List of tasks to process
Returns: List of formatted outputs

Usage Examples

Basic Usage with Default Council

Custom Council Members

Batch Processing

Different Output Formats

Non-Verbose Mode

With verbose=True, the council logs one line per stage:

Default Council Members

When no custom members are provided, the default council includes: The agent names do not always match the model: the Gemini councilor runs on gemini-2.5-flash. The default council calls four providers, so you need credentials for OpenAI, Anthropic, xAI, and Google. LiteLLM routes the unprefixed gemini-2.5-flash to Vertex AI. If you only have API keys, pass your own council_members, for example with gemini/gemini-2.5-flash.

Prompts

All council prompts live in swarms.prompts.llm_council_prompts. Use them to give custom members the same personas:

Evaluation Process

Each council member evaluates all responses (anonymized) and provides:
  1. Rankings: Ordered list from best to worst response
  2. Reasoning: Explanation for each ranking
  3. Observations: Additional insights about strengths/weaknesses
Example evaluation format:

Synthesis Process

The Chairman agent:
  1. Reviews all original responses
  2. Considers all evaluations and rankings
  3. Identifies strongest elements from each response
  4. Creates cohesive final answer incorporating best aspects
  5. Acknowledges which perspectives influenced the synthesis

Output Structure

The full conversation (for example with output_type="dict") looks like this. The default "dict-all-except-first" omits the first User entry.

Features

  • Parallel Execution: All council members respond simultaneously
  • Anonymous Evaluation: Responses are anonymized during peer review
  • Multi-Model Diversity: Leverages different LLM strengths
  • Peer Review: Each member evaluates all responses objectively
  • Intelligent Synthesis: Chairman creates cohesive final answer
  • Transparent Process: Full conversation history available
  • Flexible Output: Multiple output format options
  • Batch Processing: Handle multiple queries efficiently

Best Practices

  1. Council Composition: Include agents with complementary strengths
  2. Clear Queries: Provide well-defined questions for best results
  3. Output Type: Use "final" for end-user answers, and the default "dict-all-except-first" or "dict" for analysis
  4. Custom Members: Tailor council to your domain/use case
  5. Verbose Mode: Enable for understanding the decision process