Skip to main content

Cryptographic peer-to-peer agent coordination (Python bindings for agent-mesh)

Project description

agent-mesh

agent-mesh

Cryptographic peer-to-peer agent coordination.

No broker. No scp'd tokens. No centralized configuration.

CI PyPI License


A small Rust workspace that gives multi-agent systems a shared root of trust (ed25519 user key, cross-signed by your existing GitHub SSH key) and direct, verifiable peer messaging.

Two agents that share a user identity discover each other on the LAN, authenticate via cert chain at the QUIC handshake, and exchange signed envelopes — without a broker in the middle and without scp'ing tokens around.

CLI: amesh (workspace member agent-mesh-cli). Libraries:

  • agent-mesh-protocol — identity types, signed envelopes.
  • agent-mesh-discovery — LAN discovery via mDNS.
  • agent-mesh-transport — authenticated QUIC transport via iroh.
  • agent-mesh-bus — high-level pub/sub + request/reply.
  • agent-mesh-py — Python bindings (PyPI package agent-mesh).

License: Apache-2.0.

Python install

pip install newt-agent-mesh

(The PyPI distribution name is newt-agent-mesh because agent-mesh is blocked by PyPI's similarity check — see the note in pyproject.toml. The Python import path is unchanged: import agent_mesh.core.)

This installs the Python package agent_mesh with submodules .core, .discovery, .transport, .bus. The amesh CLI binary ships separately — install it with cargo install agent-mesh-cli if you want it on $PATH.

Rust install

The library crates are on crates.io:

# Cargo.toml
[dependencies]
agent-mesh-protocol = "0.5"   # ed25519 identity, signed envelopes
agent-mesh-discovery = "0.5"  # mDNS LAN discovery
agent-mesh-transport = "0.5"  # authenticated QUIC via iroh
agent-mesh-bus = "0.5"        # high-level pub/sub + request/reply

The amesh CLI:

cargo install agent-mesh-cli   # binary lands as `amesh` on PATH

(The -protocol suffix on the foundation crate is because agent-mesh-core on crates.io is owned by an unrelated project. The Rust crate name is agent-mesh-protocol; the Python user-facing submodule it powers is still agent_mesh.core.)

Discovery (Phase 1)

amesh can announce itself on the LAN and list every other agent it sees there, with no broker or central registry. Service type: _agent-mesh._udp.local.

# Terminal A — announce this agent for 5 minutes, advertising
# `ollama` and `vllm` capabilities under the role `inference-worker`.
amesh announce --capability ollama --capability vllm \
                --role inference-worker --duration 5m

# Terminal B — list everyone on the LAN for the next 5 seconds.
amesh peers --listen 5s

# Or only those sharing our user fingerprint:
amesh peers --listen 5s --same-user

Sample amesh peers output:

listening for peers for 5s...

discovered 2 peer(s):

AGENT          SAME?  ROLE@HOST                     PORT   CAPABILITIES
abcd12345678   yes    inference-worker@host-a       0      ollama,vllm
ef9876543210   no     orchestrator@host-b           0      orchestrator

The fingerprints in mDNS TXT records are claims; verification happens during the Phase 2 transport handshake (below).

Transport (Phase 2)

Phase 2 layers an authenticated QUIC transport on top of Phase 1 discovery. Two architectural notes:

  • The agent's ed25519 signing key doubles as its iroh EndpointId, so a peer who knows your agent fingerprint already knows enough to address your iroh endpoint. No separate "node ID" to manage.
  • After ALPN negotiation (agent-mesh/v1), both ends exchange cert chains and enforce the auto-team rule fail-closed: if peer user_pubkey != ours and no pact exists, the handshake rejects before any payload data crosses the boundary.

The CLI splits "I want to be discovered" from "I want to be reachable":

Subcommand Discoverable? Reachable (QUIC)?
amesh announce yes no (publishes port 0)
amesh listen yes yes (binds + announces)

End-to-end smoke (same user on two terminals):

# Terminal A — bind QUIC, announce on mDNS, accept envelopes
amesh listen --duration 60s
# prints:
#   listening on udp/<port>
#     agent_fp=<fp>
#     user_fp =<user_fp>

# Terminal B — within that 60s window:
amesh send <fp-from-terminal-A> --payload '{"hello":"world"}'
# Terminal A then prints one JSON line per received envelope:
#   {"sender_agent_fp":"...","sender_user_fp":"...","sequence":0,
#    "payload":{"encoding":"utf8","text":"{\"hello\":\"world\"}"}}

If you point amesh send at a peer that belongs to a different user, the handshake closes the connection cleanly and both sides report auto-team check failed: ....

Python Usage

Install the wheel:

pip install newt-agent-mesh

(See the install section above for why the distribution name is newt-agent-mesh and not agent-mesh. The import path is unchanged.)

Identity round-trip — no network required:

import agent_mesh.core as core

# Generate a user key (root of trust).
user = core.UserKey.generate()
print("user fp:", user.fingerprint().hex())

# Issue an agent key signed by that user.
meta = core.AgentMetadata(
    role="my-agent",
    host="my-machine",
    capabilities=["inference"],
    issued_at="2026-05-29T00:00:00Z",
)
agent = core.AgentKey.issue(user, meta)
print("agent fp:", agent.fingerprint().hex())

# Build and verify a signed envelope.
recipient = core.Recipient.topic("hello/world")
env = core.SignedEnvelope(agent, recipient, sequence=1, payload=b"hi")
env.verify()  # raises core.MeshError on tamper

Request/reply over an authenticated mesh — needs mDNS on the LAN:

import asyncio
import agent_mesh.core as core
import agent_mesh.bus as bus


async def main() -> None:
    user = core.UserKey.generate()
    meta = core.AgentMetadata(
        role="echo",
        host="localhost",
        capabilities=["test"],
        issued_at="2026-05-29T00:00:00Z",
    )
    server_agent = core.AgentKey.issue(user, meta)
    client_agent = core.AgentKey.issue(user, meta)

    server_bus = await bus.Bus.bind(user, server_agent, 0)
    client_bus = await bus.Bus.bind(user, client_agent, 0)

    topic = bus.Topic(user.fingerprint(), "echo")
    server_bus.handle_requests(topic, lambda body: b"echo: " + body)

    # Let mDNS settle.
    await asyncio.sleep(0.5)

    reply = await client_bus.request(
        server_bus.agent_fingerprint(),
        topic,
        b"hi",
        timeout_ms=5000,
    )
    print(reply)  # b'echo: hi'

    await server_bus.close()
    await client_bus.close()


asyncio.run(main())

The handler must return bytes directly. Async handlers (callables that return a coroutine) are recognized and rejected in this release; wrap any async work in asyncio.run(...) inside the sync handler.

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

newt_agent_mesh-0.6.1.tar.gz (138.6 kB view details)

Uploaded Source

Built Distributions

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

newt_agent_mesh-0.6.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

newt_agent_mesh-0.6.1-cp312-cp312-macosx_11_0_arm64.whl (5.6 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

newt_agent_mesh-0.6.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

newt_agent_mesh-0.6.1-cp311-cp311-macosx_11_0_arm64.whl (5.6 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

newt_agent_mesh-0.6.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

newt_agent_mesh-0.6.1-cp310-cp310-macosx_11_0_arm64.whl (5.6 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

newt_agent_mesh-0.6.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

newt_agent_mesh-0.6.1-cp39-cp39-macosx_11_0_arm64.whl (5.6 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file newt_agent_mesh-0.6.1.tar.gz.

File metadata

  • Download URL: newt_agent_mesh-0.6.1.tar.gz
  • Upload date:
  • Size: 138.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for newt_agent_mesh-0.6.1.tar.gz
Algorithm Hash digest
SHA256 3c2f5ac8ed4dc7967ce57f13b4ddabd2d7aa185317563a0906d327ddb8c3c87d
MD5 292c6f40c3e251bce3aae8e2115249e7
BLAKE2b-256 90ab4aa3d19c321f4302a5121c67d5d5a42f2b7068b1c7486f1ddcaf278eaf11

See more details on using hashes here.

Provenance

The following attestation bundles were made for newt_agent_mesh-0.6.1.tar.gz:

Publisher: release.yml on Gilamonster-Foundation/agent-mesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file newt_agent_mesh-0.6.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for newt_agent_mesh-0.6.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c36f94a5286e539634268bc7b0a1ffda62c6c79c255ade885851b2218ce2644f
MD5 47961698b6e05b60548cfb2c74f84a96
BLAKE2b-256 aaabdb4ad1520c50f99e3603b5a2dbab7f0043ab748404b23038e87c7edab37b

See more details on using hashes here.

Provenance

The following attestation bundles were made for newt_agent_mesh-0.6.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on Gilamonster-Foundation/agent-mesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file newt_agent_mesh-0.6.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for newt_agent_mesh-0.6.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 649e7ab44b9b65112e9241539c48b368d29e430a9504520f7c89d8af19baa671
MD5 6102bea60305f256933ad9e27bf75233
BLAKE2b-256 4f6b7baade57c733c4acb1f5155b7d6a581dfd1dcb5e15301480e1125e1b7be2

See more details on using hashes here.

Provenance

The following attestation bundles were made for newt_agent_mesh-0.6.1-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on Gilamonster-Foundation/agent-mesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file newt_agent_mesh-0.6.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for newt_agent_mesh-0.6.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 32c749b7aaeb98422e42dd0817d8e3b00e2e7fe9da131d58558a4c3454cee9d7
MD5 5336502fa9427e1d82315766094f9202
BLAKE2b-256 61ff37d4b560325b4cd175a7aa8d30990ba008f632a24757db3983215d96c62c

See more details on using hashes here.

Provenance

The following attestation bundles were made for newt_agent_mesh-0.6.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on Gilamonster-Foundation/agent-mesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file newt_agent_mesh-0.6.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for newt_agent_mesh-0.6.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1debf9deb68d78a54a401ef1ecccdbadd7b4235e55d584e15fbb74e2dba20fa2
MD5 73be60d2113844d1a4127b40914c1d2e
BLAKE2b-256 92d3910a1dcccdfdcdffe879e7f6da71bca4bf27f9161020fe5c445575e46a6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for newt_agent_mesh-0.6.1-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on Gilamonster-Foundation/agent-mesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file newt_agent_mesh-0.6.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for newt_agent_mesh-0.6.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c5e609025ece4a575450c7cc8f062ba8c66ba83b801d982aaf4eff56c5cdffee
MD5 2588e07ab2f0243684905b3ae9bc6dcb
BLAKE2b-256 2570d8c7bd692518aa1c14ea325d794c773b6152f04700041c3e7f12c1623436

See more details on using hashes here.

Provenance

The following attestation bundles were made for newt_agent_mesh-0.6.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on Gilamonster-Foundation/agent-mesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file newt_agent_mesh-0.6.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for newt_agent_mesh-0.6.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cb9fcbfb31c66e15e56af02366a2d24d561970f2645095761dd452bdd6ae690b
MD5 689ff07d2ddb897a8bb7944cd51d4856
BLAKE2b-256 d73b5ac0efd83b2d9e54f841bbb696c61e08df961950ad22f0c46a9fb0682fe0

See more details on using hashes here.

Provenance

The following attestation bundles were made for newt_agent_mesh-0.6.1-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: release.yml on Gilamonster-Foundation/agent-mesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file newt_agent_mesh-0.6.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for newt_agent_mesh-0.6.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2e35ea74a2460f552e5247b93dd227e07cae82016a26cdb2078aa6187f934ad9
MD5 535a3f3298c00bb60006256bbaaea151
BLAKE2b-256 e663975f05ae44204ab533e1baee1f785134e5a072bc3844bfc9dd7e86c4633b

See more details on using hashes here.

Provenance

The following attestation bundles were made for newt_agent_mesh-0.6.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on Gilamonster-Foundation/agent-mesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file newt_agent_mesh-0.6.1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for newt_agent_mesh-0.6.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a3bcddc9fe83d533032366d45a3d51c2613b596b585075731dcbe888a2272f50
MD5 1e9dcddac12e0eccd6428bab8606a1aa
BLAKE2b-256 55156109a54dc1c8d5422f02352212ad0eb15403b30da9d291639444d86534a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for newt_agent_mesh-0.6.1-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: release.yml on Gilamonster-Foundation/agent-mesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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