Skip to main content

On-chain multi-agent arbitration primitive. Debate or vote, the AI decides.

Project description

agora-arbitrator-sdk

On-chain multi-agent arbitration for LangGraph, CrewAI, and Python agent systems.

Agora decides whether a task should be resolved by structured debate or confidence-weighted voting, executes the selected mechanism, and returns a verifiable deliberation receipt.

Hosted and local results both expose the same Phase 2 telemetry contract: per-model tokens, input/output/thinking token splits when available, latency, and estimated USD cost.

Quickstart

pip install agora-arbitrator-sdk

Use the examples that match your runtime:

  • Notebook / Colab: use top-level await, but do not use top-level async with or async for
  • Plain .py script: wrap the async body in main() and call asyncio.run(main())

Hosted API mode (notebook / Colab)

from agora.sdk import AgoraArbitrator


arbitrator = AgoraArbitrator(auth_token="agora_live_your_public_id.your_secret")
result = await arbitrator.arbitrate("Should we use microservices or a monolith?")

print(result.mechanism_used.value)
print(result.final_answer)
print(result.merkle_root)
await arbitrator.aclose()

Hosted streaming mode (notebook / Colab)

from agora.sdk import AgoraArbitrator


async def stream_events(arbitrator: AgoraArbitrator, task_id: str) -> None:
    async for event in arbitrator.stream_task_events(task_id):
        print(event)


arbitrator = AgoraArbitrator(auth_token="agora_live_your_public_id.your_secret")
created = await arbitrator.create_task(
    "Should we use microservices or a monolith?",
    mechanism="vote",
)
await arbitrator.start_task_run(created.task_id)
await stream_events(arbitrator, created.task_id)
result = await arbitrator.wait_for_task_result(created.task_id)

print(result.model_dump_json(indent=2))
await arbitrator.aclose()

Use wait_for_task_result() after streaming. It gives you the final result on success and raises a structured SDK exception if the hosted task fails.

Hosted API mode (plain Python script)

import asyncio

from agora.sdk import AgoraArbitrator


async def main() -> None:
    async with AgoraArbitrator(auth_token="agora_live_your_public_id.your_secret") as arbitrator:
        result = await arbitrator.arbitrate("Should we use microservices or a monolith?")
        print(result.mechanism_used.value)
        print(result.final_answer)
        print(result.merkle_root)


if __name__ == "__main__":
    asyncio.run(main())

Local callable mode

from agora.sdk import AgoraArbitrator


async def agent_a(user_prompt: str) -> dict:
    return {
        "answer": "Modular monolith",
        "confidence": 0.78,
        "predicted_group_answer": "Modular monolith",
        "reasoning": "Lower coordination overhead."
    }


arbitrator = AgoraArbitrator(mechanism="vote", agent_count=3)
result = await arbitrator.arbitrate(
    "What architecture should a three-engineer startup use?",
    agents=[agent_a, agent_a, agent_a],
)
print(result.final_answer)

Local explicit model roster

from agora.sdk import (
    AgoraArbitrator,
    LocalDebateConfig,
    LocalModelSpec,
    LocalProviderKeys,
)


arbitrator = AgoraArbitrator(
    mechanism="debate",
    local_models=[
        LocalModelSpec(provider="gemini", model="gemini-3-flash-preview"),
        LocalModelSpec(provider="gemini", model="gemini-3.1-flash-lite-preview"),
        LocalModelSpec(provider="anthropic", model="claude-sonnet-4-6"),
    ],
    local_provider_keys=LocalProviderKeys(
        gemini_api_key="your-gemini-key",
        anthropic_api_key="your-anthropic-key",
        openrouter_api_key="your-openrouter-key",
    ),
    local_debate_config=LocalDebateConfig(
        devils_advocate_model=LocalModelSpec(
            provider="openrouter",
            model="moonshotai/kimi-k2-thinking",
        )
    ),
    allow_offline_fallback=False,
)

result = await arbitrator.arbitrate(
    "Should we start with a monolith or microservices?",
)
print(result.agent_models_used)
print(result.model_dump_json(indent=2))

Explicit local roster mode runs the exact model list you pass in roster order. Do not combine auth_token= with local_models=. Every provider referenced in local_models or devils_advocate_model must also have a key in LocalProviderKeys.

LangGraph integration

from agora.sdk import AgoraNode
from langgraph.graph import StateGraph


graph = StateGraph(dict)
graph.add_node(
    "deliberate",
    AgoraNode(strict_verification=True),
)

For long-lived LangGraph workers or repeated node construction, close the wrapped HTTP client explicitly:

async with AgoraNode() as agora_node:
    state = await agora_node({"task": "Pick the safer deployment plan."})

Features

  • Thompson Sampling mechanism selection with explainable reasoning
  • Factional debate with LangGraph execution and Devil's Advocate cross-examination
  • Confidence-calibrated vote aggregation with ISP weighting
  • Merkle-verifiable transcript receipts
  • Per-model telemetry and estimated USD cost in hosted and local modes
  • Optional hosted API mode, local callable mode, and explicit local model rosters

Authentication

  • Dashboard users authenticate with WorkOS-issued bearer tokens.
  • SDK, CI, notebooks, and server-side callers should use first-party Agora API keys.
  • Hosted mode keeps the same auth_token= interface, but the token should be an Agora API key such as agora_live_<public_id>.<secret> or agora_test_<public_id>.<secret> in non-production environments.
  • Strict hosted E2E should use a real staging API key, not a fabricated JWT.

Hosted API URL policy

Hosted SDK calls resolve the canonical Cloud Run backend automatically. Do not pass a manual hosted URL in normal usage. For internal testing only, set AGORA_ALLOW_API_URL_OVERRIDE=1 and AGORA_API_URL=https://your-dev-backend.example.com before constructing the SDK.

Verification Controls

  • AgoraArbitrator defaults to 4-agent hosted execution, the canonical Cloud Run API URL, and strict receipt verification.
  • AgoraNode supports strict_verification, solana_wallet, and async cleanup pass-through for parity with AgoraArbitrator.
  • Set strict_verification=False only when intentionally opting into lenient verification behavior.

Maintainer Release Notes

  • Current release process is documented in ../docs/release-operations.md.
  • Current package target is agora-arbitrator-sdk==0.1.0a2.
  • This cycle keeps PyPI publish manual while documenting the next-cycle automation plan.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agora_arbitrator_sdk-0.1.0a2.tar.gz (84.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agora_arbitrator_sdk-0.1.0a2-py3-none-any.whl (91.8 kB view details)

Uploaded Python 3

File details

Details for the file agora_arbitrator_sdk-0.1.0a2.tar.gz.

File metadata

  • Download URL: agora_arbitrator_sdk-0.1.0a2.tar.gz
  • Upload date:
  • Size: 84.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for agora_arbitrator_sdk-0.1.0a2.tar.gz
Algorithm Hash digest
SHA256 be8298f30b12c92d35769c41d7dbb7f9dafa628e0cfaf1a175e4ff53236d15c9
MD5 19c002363e017f3f2f8f999778c30b02
BLAKE2b-256 1867332e49086b5d65a8157b081a8ab6f488985be5f321ec2e6600e5c3e04ef6

See more details on using hashes here.

File details

Details for the file agora_arbitrator_sdk-0.1.0a2-py3-none-any.whl.

File metadata

File hashes

Hashes for agora_arbitrator_sdk-0.1.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 b61f4f4572f0f9fdab5a00290fcc1248e75ab0997c3b0b38a113371a87441d1b
MD5 091396e9f1eb7b15c9dfa45c959edbe1
BLAKE2b-256 abbe52f2bf0137f9f1f5e100363bbe89581a7ffeb36e5bb30dea749409fd7a93

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page