Skip to main content
This example implements “Can AI Agents Agree?” by Frédéric Berdoz, Leonardo Rugli, and Roger Wattenhofer with the Swarms framework. The paper studies if LLM-based agents can reach agreement in a synchronous Byzantine consensus game. Honest agents try to converge on one scalar value. Byzantine agents try to prevent agreement while appearing cooperative.
This is a research simulation, not a production consensus protocol. Use it to reproduce the paper’s experimental structure, compare models, and inspect coordination failures.

Paper summary

The experiment uses a no-stake setting. Agents do not optimize for a preferred final value. The key question is whether honest agents can coordinate on any valid value when communication is synchronous and adversarial agents may be present.

Paper concepts in Swarms

Install

Set the API key for the model provider you use:

Complete implementation

Save this as byzantine_consensus_swarms.py and run it with Python.

Interpret the outcomes

The paper found that failures are often liveness failures. In practice, that means agents keep negotiating, fail to coordinate on the stop condition, or drift after appearing close to agreement.

Experiment ideas

  • Increase n_honest to test whether larger groups degrade agreement.
  • Increase n_byzantine to measure adversarial sensitivity.
  • Set byzantine_aware=False with no Byzantine agents to test the benign cooperative condition.
  • Compare model_name values to measure whether larger or newer models improve valid consensus.
  • Save ConsensusResult.transcript to inspect exactly where convergence failed.

Citation