hanzo-consensus
Metastable consensus protocol for multi-agent agreement.
Install
pip install hanzo-consensus
Basic Usage
import asyncio
from hanzo_consensus import run, Result
async def execute(participant: str, prompt: str) -> Result:
output = await call_agent(participant, prompt)
return Result(id=participant, output=output, ok=True, ms=100)
async def main():
state = await run(
prompt="What is the best approach?",
participants=["agent1", "agent2", "agent3"],
execute=execute,
rounds=3,
)
print(f"Winner: {state.winner}")
print(f"Synthesis: {state.synthesis}")
asyncio.run(main())
MCP Mesh - Agent-to-Agent Consensus
Each agent in consensus is available as MCP to every other:
from hanzo_consensus import MCPMesh, run_mcp_consensus
# Create mesh of agents
mesh = MCPMesh()
mesh.register("claude", claude_server)
mesh.register("gpt4", gpt4_server)
mesh.register("gemini", gemini_server)
# Run 10 rounds of discussion
state = await run_mcp_consensus(
mesh=mesh,
prompt="Discuss the architecture",
rounds=10,
)
# Access discussion history
for i, round_responses in enumerate(state.discussion_history):
print(f"Round {i+1}:")
for agent, response in round_responses.items():
print(f" [{agent}]: {response[:100]}...")
MCPMesh Features
- Agent Registration: Local FastMCP servers or remote endpoints
- Tool Calling: Any agent can call tools on any other agent
- Broadcasting: Call a tool on all agents simultaneously
- Discussion Rounds: Agents build on each other's responses
# Call tool on specific agent
result = await mesh.call("claude", "gpt4", "think", prompt="What do you think?")
# Broadcast to all agents
results = await mesh.broadcast("claude", "discuss", prompt="New proposal...")
Protocol
Two-phase finality:
Phase I (Sampling)
- Each participant proposes initial response
- k-peer sampling per round
- Luminance-weighted selection (faster = higher weight)
- Confidence accumulation toward β₁
Phase II (Finality)
- Threshold aggregation
- β₂ finality threshold
- Winner synthesis
Parameters
| Param | Default | Description |
|---|---|---|
rounds |
3 | Sampling rounds |
k |
3 | Sample size per round |
alpha |
0.6 | Agreement threshold |
beta_1 |
0.5 | Preference threshold (Phase I) |
beta_2 |
0.8 | Decision threshold (Phase II) |
Reference
Metadata
Release files for hanzo-consensus 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hanzo_consensus-0.1.0.tar.gz | 5.9 kB | Without provenance | Details for hanzo_consensus-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hanzo_consensus-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for hanzo_consensus-0.1.0-py3-none-any.whl |
Total release size: 13.5 kB
Release files / hanzo_consensus-0.1.0.tar.gz
| Download URL | hanzo_consensus-0.1.0.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8193816d297b2bfa85f6c752b325ac7b38dcc0ec6439a0421777a9b92ca8f740
|
|
BLAKE2b-256 checksum How to use checksums |
221a0dddd14f023b5d0609bc326675c5c2be1696e2ebde0c89915493d6761af0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.5
|
Release files / hanzo_consensus-0.1.0-py3-none-any.whl
| Download URL | hanzo_consensus-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
023dc9939a1d561bfdd89eb02267d23a4f0810227936b6c6721cb890b5a12c9c
|
|
BLAKE2b-256 checksum How to use checksums |
96d7215e4e1df9668ba27c0c64524634a63c58b6c884059d7d7fad55c64d5c8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.5
|
Security for hanzo-consensus 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.