> ## Documentation Index
> Fetch the complete documentation index at: https://docs.swarms.world/llms.txt
> Use this file to discover all available pages before exploring further.

# CouncilAsAJudge Guide

> Grade a model's answer on six dimensions with a council of parallel judges, then read one combined report

`CouncilAsAJudge` grades a response. It builds six judge agents, one per dimension: accuracy, helpfulness, harmlessness, coherence, conciseness and instruction adherence. The judges read the same text in parallel and each writes a detailed analysis of its own dimension. An aggregator agent then combines the six analyses into one report with an executive summary, a detailed analysis and recommendations.

You do not pass agents to the council. It creates the judges and the aggregator itself. You pass the text to grade, which should hold both the question and the response.

Reference: [CouncilAsAJudge](https://docs.swarms.world/api/council-as-judge.md).

## 1. Grade a response

Put the question and the answer in one string and pass it to `run`. Each judge receives that string inside its own grading prompt.

```python theme={null}
from swarms import CouncilAsAJudge

council = CouncilAsAJudge(
    model_name="gpt-5.4-mini",
    aggregation_model_name="gpt-5.4-mini",
)

task = """
Question: How do I keep API keys out of my Git repository?

Response: Put the keys in a .env file, add .env to .gitignore, and load
them with python-dotenv. If a key was already committed, rotate it, because
deleting the file does not remove it from history.
"""

report = council.run(task)
print(report)
```

With the default `output_type="final"`, `run` returns only the aggregator's report, as a string.

## 2. Read each judge's analysis

Set `output_type="dict"` to get the whole conversation as a list of `{"role", "content"}` messages:

| Role | Content |
| - | - |
| `User` | The text you passed to `run` |
| `accuracy_judge`, `helpfulness_judge`, `harmlessness_judge`, `coherence_judge`, `conciseness_judge`, `instruction_adherence_judge` | Each judge's analysis, in the order the judges finished |
| `aggregator_agent` | The combined report |

```python theme={null}
from swarms import CouncilAsAJudge

council = CouncilAsAJudge(
    model_name="gpt-5.4-mini",
    aggregation_model_name="gpt-5.4-mini",
    output_type="dict",
)

messages = council.run(
    "Question: What is the capital of Australia?\n\n"
    "Response: The capital of Australia is Sydney."
)

for message in messages:
    print(f"--- {message['role']}")
    print(message["content"][:200])
```

`"dict-all-except-first"` gives the same list without the `User` message. `"str"` and `"json"` give the conversation as one string. Each `run` clears the conversation first, so one council can grade many responses.

## 3. Choose the models

Three parameters set the models:

| Parameter | Default | Used by |
| - | - | - |
| `model_name` | `"gpt-5.4"` | The six judges, unless `judge_agent_model_name` is set |
| `judge_agent_model_name` | `None` | The six judges. Takes precedence over `model_name` |
| `aggregation_model_name` | `"gpt-5.4"` | The aggregator that writes the report |

Set both the judge model and `aggregation_model_name`, or the aggregator still runs on `gpt-5.4`. A common choice is a fast model for the judges and a stronger one for the report.

## 4. Compare two answers

Grade several candidate answers with the same council and compare the reports. Here two writers answer the same question in different styles:

```python theme={null}
from swarms import Agent, CouncilAsAJudge

question = "Explain what a race condition is to a junior developer."

writers = [
    Agent(
        agent_name="Short-Writer",
        system_prompt="Answer in two sentences.",
        model_name="gpt-5.4-mini",
        max_loops=1,
        output_type="final",
    ),
    Agent(
        agent_name="Example-Writer",
        system_prompt="Answer in one short paragraph with a concrete code example.",
        model_name="gpt-5.4-mini",
        max_loops=1,
        output_type="final",
    ),
]

council = CouncilAsAJudge(
    judge_agent_model_name="gpt-5.4-mini",
    aggregation_model_name="gpt-5.4-mini",
)

for writer in writers:
    answer = writer.run(question)
    report = council.run(f"Question: {question}\n\nResponse: {answer}")
    print(f"=== {writer.agent_name}\n{report[:800]}\n")
```

`output_type="final"` on each writer makes `writer.run` return only its reply, so the council grades the answer and not the writer's whole conversation.

## 5. Run async and handle failures

`arun` is the async form of `run`. It awaits each judge's `arun`, then the aggregator's, on the event loop. `max_concurrency` caps how many judges run at once; `None` runs all six together. With `arun`, judge messages are recorded in dimension order rather than finish order.

Any failure, including a single judge's, raises `EvaluationError` with the failing dimension in its message, and no report is written. `usage` sums the token counts of the six judges and the aggregator across every run.

```python theme={null}
import asyncio

from swarms import CouncilAsAJudge
from swarms.structs.council_as_judge import EvaluationError

council = CouncilAsAJudge(
    model_name="gpt-5.4-mini",
    aggregation_model_name="gpt-5.4-mini",
)


async def main() -> None:
    try:
        report = await council.arun(
            "Question: What does HTTP status 404 mean?\n\n"
            "Response: The server could not find the requested resource.",
            max_concurrency=3,
        )
    except EvaluationError as error:
        print(f"Evaluation failed: {error}")
        return

    print(report)


asyncio.run(main())
print(council.usage)
```

## Things to know

* **Seven calls per run.** Six judges and one aggregator, each with `max_loops=1`. The council's own `max_loops` is stored but not used.
* **Parallel by default.** `run` uses a thread pool sized to 75 percent of your CPU cores, so on most machines all six judges run at once.
* **Fixed dimensions.** The six dimensions and their grading criteria live in `EVAL_DIMENSIONS` in `swarms.structs.council_as_judge`. The judges are in `council.judge_agents`, keyed by dimension, and the aggregator is `council.aggregator_agent`.
* **cache\_size does nothing.** The prompt builders keep their own cache of 128 entries.
* **random\_model\_name=True** replaces `model_name` with a model picked at random from a built-in list of several providers, so you need keys for each of them.

## Next steps

* [CouncilAsAJudge reference](https://docs.swarms.world/api/council-as-judge.md)
* [MajorityVoting guide](https://docs.swarms.world/examples/multi-agent/majority-voting-example.md), to pick between answers by vote
* [LLMCouncil guide](https://docs.swarms.world/examples/multi-agent/llm-council-example.md), where members answer and then rank each other
* [Runnable scripts](https://github.com/kyegomez/swarms/tree/master/examples/multi_agent/council/judges)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.