Skip to main content
LLMCouncil runs a question through three stages. First, every council member answers it on its own, in parallel. Next, every member reads all the answers, relabelled Response A, Response B and so on in a shuffled order, and ranks them without knowing who wrote which. Last, a Chairman agent reads the answers, the rankings and who wrote what, and writes one final answer. It is based on Andrej Karpathy’s llm-council. Use it when you want several models or personas to check each other’s work before you get an answer. Reference: LLMCouncil.

1. Run a council with your own members

Pass any agents as council_members. The council builds the Chairman itself, on chairman_model, which defaults to gpt-5.1. With output_type="final", run returns only the Chairman’s answer.
A run makes 2 * len(council_members) + 1 model calls: each member answers once and ranks once, then the Chairman writes once. Every run resets the members and the Chairman to a fresh conversation, so one council can take many questions. With the default verbose=True, the council logs one line per stage. Pass verbose=False to turn those off.

2. Read the whole session

The default output_type is "dict-all-except-first": every message after the question, as a list of {"role", "content"} dicts. This continues from the block above and reuses members:
Each evaluation starts with a RANKINGS: list such as 1. Response C: .... Members rank their own answer too, without knowing which one it is. The labels are shuffled on every run, and only the Chairman gets the mapping from labels to members. Other output_type values:
  • "final" returns the Chairman’s answer as a string.
  • "dict" or "list" include the question as the first User message.
  • "str", "json" and "yaml" return the whole session as one string.

3. Use the preset councilors

Without council_members, the council builds four preset members, each with its own persona prompt: The defaults call four providers, so you need an OpenAI, Gemini, Anthropic and xAI key. council_models replaces the four models, in that order, and keeps the personas. It must hold exactly four names, or the constructor raises ValueError. Here every seat runs on one provider:
To give your own agents the same personas, use the prompt functions in swarms.prompts.llm_council_prompts, such as get_gpt_councilor_prompt(), as their system_prompt.

4. Many questions and token usage

batched_run(tasks) runs the council once per task, one after another, and returns a list of results in task order. usage sums the token counts of every member and the Chairman across every run. This continues from the first block:

Errors

  • run raises ValueError if the task is not a string, is empty or is only whitespace.
  • If any member fails while answering or ranking, run raises that member’s error, such as AgentLLMError, and the Chairman does not run. With the preset council, a missing or empty key for any one of the four providers stops the run this way.

Tips

  • Diverse members rank better. Members on different models or with different personas disagree more, which gives the rankings something to decide.
  • Keep member answers short. Every member reads every answer in the ranking stage, so long answers multiply the input tokens.
  • Use a strong Chairman. The Chairman writes the only answer most callers read. A small model for members and a stronger one for chairman_model is a good split.

Next steps