Vote — majority rules

Each agent returns a classification or short answer. Take the majority. Simple, robust, cheap.

String consensus = results.stream()
    .map(AgentResponse::text)
    .collect(Collectors.groupingBy(s -> s, Collectors.counting()))
    .entrySet().stream()
    .max(Map.Entry.comparingByValue())
    .map(Map.Entry::getKey)
    .orElse("no consensus");
Advertisement

Judge — LLM picks the best

Pass all N answers to a small, cheap judge agent. It picks the best one with a short explanation. Costs one extra call.

Advertisement

Merge — deterministic combination

When answers are structured (JSON, lists), merge programmatically — union sets, sum values, deduplicate.