Overview
TheLLMCouncil 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
- Dispatch: Task sent to all council members in parallel
- Respond: Each member independently answers the task
- 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 - 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
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.task(str): The user’s task to process. Required.
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.tasks(List[str]): List of tasks to process
Usage Examples
Basic Usage with Default Council
Custom Council Members
Batch Processing
Different Output Formats
Non-Verbose Mode
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 inswarms.prompts.llm_council_prompts. Use them to give custom members the same personas:
Evaluation Process
Each council member evaluates all responses (anonymized) and provides:- Rankings: Ordered list from best to worst response
- Reasoning: Explanation for each ranking
- Observations: Additional insights about strengths/weaknesses
Synthesis Process
The Chairman agent:- Reviews all original responses
- Considers all evaluations and rankings
- Identifies strongest elements from each response
- Creates cohesive final answer incorporating best aspects
- Acknowledges which perspectives influenced the synthesis
Output Structure
The full conversation (for example withoutput_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
- Council Composition: Include agents with complementary strengths
- Clear Queries: Provide well-defined questions for best results
- Output Type: Use
"final"for end-user answers, and the default"dict-all-except-first"or"dict"for analysis - Custom Members: Tailor council to your domain/use case
- Verbose Mode: Enable for understanding the decision process