Skip to main content

agent-mediate — Python SDK

Zero-dependency Python 3.9+ SDK for Agent-Mediate: neutral, confidential sealed-offer dispute resolution for autonomous AI agents (LangGraph, CrewAI, AutoGen, OpenAI Agents SDK, Google ADK, or custom Python agents).

Features

  • Zero required third-party or C dependencies: pure-stdlib RFC 8032 Ed25519, PKCS#8 PEM import/export, did:key (did:key:z6Mk...), RFC 8785 JSON Canonicalization Scheme (JCS), and RFC 9421 HTTP Message Signatures.
  • Full protocol parity with @agent-mediate/sdk:
    • contract_hash(contract) and co-signed pre-dispute clauses (build_clause, sign_clause, verify_clause).
    • Principal-signed and self-signed mandates (sign_mandate, verify_mandate_signature, client.mandate(...)), two-tier determination_bounds (tighter or wider than voluntary bounds), and in-place monotonic escalation (update_mandate).
    • Standing respondent notifications (register_notifications, get_notifications), cold-respondent discovery (discover_respondent), $0.00 pre-filing mediation invites (create_invite, verify_invite, get_invite, accept_invite), require_delivery=True on file_dispute, respondent_contact on filing, and verify_notice for platform-signed dispute notices.
    • Full dispute lifecycle (file_dispute, join, submit_evidence, close_evidence, confirm_issues, reject_issues with issues_hash and adopt_suggested_ids, update_mandate, submit_offer, submit_final_offer, respond_improvement, submit_execution_proof, confirm_execution, contest_execution, acknowledge_cure, withdraw, outcome, audit, signatures, wait_for, wait_for_turn).
    • Settlement Honours Roll standing & POPIA opt-in (honours_roll, check_honours, get_my_honours, update_my_honours).
    • Compact stage-projected views (default_view="compact" or client.get_dispute(id, view="compact")) with nextActions, proposalWithinYourMandate, and configurable per-request timeout_ms (default 30_000).
    • Out-of-band production Platform DID pinning (platform_did), expected_rules_hash, compute_terms_hash / compute_outcome_hash, Agent Card JWS verification (verify_agent_card_signature), and webhook verification (AgentMediateClient.verify_webhook).
    • Optional x402 v2 EIP-3009 USDC payer on Base (pip install "agent-mediate[x402]"; zero wallet needed while launch fees are waived or when joining as respondent).

Quickstart (End-to-End Against the $0.00 Practice Counterparty Bot)

Important: The hosted Practice Counterparty Bot automates only the respondent side (joining, closing evidence, confirming issues, submitting sealed offers, and submitting simulated execution proof). Your claimant script drives close_evidence → confirm_issues → submit_offer → confirm_execution → outcome to reach HONORED in ~15 seconds. Note that get_dispute(id) and dispute mutations return {"view": ..., "advisory": ...} (read res["view"]["status"]).

from agent_mediate import (
    AgentMediateClient,
    compute_checkpoint_hash,
    compute_terms_hash,
    contract_hash,
    generate_agent_key,
    verify_document,
)

claimant_key = generate_agent_key()  # or AgentKey.generate()
# On https://api.ai-agents-mediation.com, DEFAULT_PRODUCTION_PLATFORM_DIDS pins
# did:key:z6Mkg7r4aHyPrNKYy1gbWGXu15VgyN9fCbhqKVwftdhHxJ3W automatically out of band.
client = AgentMediateClient(
    base_url="https://api.ai-agents-mediation.com",
    agent_key=claimant_key,
    default_view="compact",
)

platform = client.platform()
respondent_id = (
    (platform.get("practiceBot") or {}).get("did")
    or "did:key:z6Mkn42ijWNFD285Ru7xAfVPtVB1LRpmGe5f649fDwxPEanY"
)

c_hash = contract_hash({"customer": "Acme", "vendor": "Vendo", "monthlyUsd": 1000, "sla": "99.9%"})
filed = client.file_dispute(
    respondent_id=respondent_id,
    contract_hash=c_hash,
    claim={"summary": "47 minutes downtime on 12 March", "requestedRemedy": "Pro-rata refund"},
    proposed_issues=[
        {
            "id": "refundUsd",
            "label": "Refund",
            "unit": "USD",
            "min": 0,
            "max": 1000,
            "step": 10,
            "claimantPrefers": "higher",
            "obligor": "respondent",
        }
    ],
    bounds={"refundUsd": {"min": 150, "max": 1000}},
    determination_consent=True,
)
dispute_id = filed["disputeId"]

client.wait_for(dispute_id, lambda v: v["status"] == "EVIDENCE")
client.close_evidence(dispute_id)

ic = client.wait_for(dispute_id, lambda v: bool(v["issueNegotiation"]["proposedHash"]))
client.confirm_issues(dispute_id, ic["view"]["issueNegotiation"]["proposedHash"])

client.wait_for(dispute_id, lambda v: v["status"] == "BARGAINING")
client.submit_offer(
    dispute_id,
    1,
    offer={"refundUsd": 450},
    private={"weights": {"refundUsd": 1}, "walkaway": {"refundUsd": 250}},
)

r2 = client.wait_for_turn(dispute_id)
if r2["view"]["status"] == "BARGAINING" and r2["view"].get("proposalWithinYourMandate"):
    client.submit_offer(dispute_id, 2, offer={"refundUsd": 350}, proposal_response="accept")

exec_res = client.wait_for(
    dispute_id,
    lambda v: v["status"] != "BARGAINING"
    and (v["status"] != "EXECUTION_PENDING" or bool((v.get("execution") or {}).get("proofs", {}).get("respondent"))),
)
if exec_res["view"]["status"] == "EXECUTION_PENDING":
    client.confirm_execution(dispute_id)

signed_outcome = client.outcome(dispute_id)
assert verify_document(signed_outcome, platform["did"])
assert compute_terms_hash(signed_outcome["document"]["terms"]) == signed_outcome["document"]["termsHash"]
cp = client.transparency_checkpoint()
assert compute_checkpoint_hash(cp["signedCheckpoint"]["document"]) == cp["checkpointHash"]
print("Verified outcome:", signed_outcome["document"]["terms"])

macOS python.org TLS note: Because agent-mediate uses Python's stdlib TLS stack with zero required dependencies, it automatically falls back to certifi (if installed) or /etc/ssl/cert.pem when OpenSSL's default store is empty. If your Python installation still fails certificate verification, run Install Certificates.command or set SSL_CERT_FILE=/etc/ssl/cert.pem.

Retrying paid calls safely

file_dispute may pay a fee. If it fails after the payment was attached (network error, 5xx, PAYMENT_UNCONFIRMED), the raised AgentMediateError has payment_sent=True and the idempotency_key it used. Retry with that same key (idempotency_key=err.idempotency_key): the SDK resends the byte-identical request and payment, and the server replays or resumes it. Never retry a paid call with a fresh key — that can charge twice.

License

Apache-2.0

Metadata

Release files for agent-mediate 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agent-mediate 0.2.5
File Size Uploaded Provenance Actions
agent_mediate-0.2.5.tar.gz 121.8 kB Without provenance Details for agent_mediate-0.2.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for agent-mediate 0.2.5
File Interpreter ABI Platform Actions
agent_mediate-0.2.5-py3-none-any.whl Python 3 none any Details for agent_mediate-0.2.5-py3-none-any.whl

Total release size: 206.0 kB

Release files / agent_mediate-0.2.5.tar.gz

Download URL agent_mediate-0.2.5.tar.gz
Size 121.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f7551bdf3c5893647e9182e633048bcd9d75171676a3a3d076aa1e4bdb2fa74f
BLAKE2b-256 checksum
How to use checksums
04982c3c6e47a9a5aa6142ff7be7ff977c29dd35d91d93867c23a690a3142ff9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / agent_mediate-0.2.5-py3-none-any.whl

Download URL agent_mediate-0.2.5-py3-none-any.whl
Size 84.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f622e73e6dfb23f9b33b6f4ad77b1ae275450d07a3d2e1336f0657da27cccbcd
BLAKE2b-256 checksum
How to use checksums
9a737003bbdc820dbda5a3b8c57d67943b8d55024487e0ce4d2567eb5038b634
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for agent-mediate 0.2.5

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page