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.2.tar.gz (141.5 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.2-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.2-cp312-cp312-macosx_11_0_arm64.whl (5.6 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

newt_agent_mesh-0.6.2-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.2-cp311-cp311-macosx_11_0_arm64.whl (5.6 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

newt_agent_mesh-0.6.2-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.2-cp310-cp310-macosx_11_0_arm64.whl (5.6 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

newt_agent_mesh-0.6.2-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.2-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.2.tar.gz.

File metadata

  • Download URL: newt_agent_mesh-0.6.2.tar.gz
  • Upload date:
  • Size: 141.5 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.2.tar.gz
Algorithm Hash digest
SHA256 00044c87c8dc8e4fa5ce649d5ba138d35c87f98b4c8ec4312c1b4bff284b9fe4
MD5 9ea014ad78806ee90b6f7830a9c49aac
BLAKE2b-256 c00cff5b67caf52550d64d003136631000508549deb01406882fac172b668d58

See more details on using hashes here.

Provenance

The following attestation bundles were made for newt_agent_mesh-0.6.2.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.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for newt_agent_mesh-0.6.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6a3cd021f8b0ec14193970f9d3cf7dc6b963e4223fa08eba087080dfef14aeb3
MD5 3d26fdadc2fa45ca92a0c8ea4be0b896
BLAKE2b-256 c793a12b68c041b495a06eae4a7d523cce8f698f5f01ac11ecfdd3840da10838

See more details on using hashes here.

Provenance

The following attestation bundles were made for newt_agent_mesh-0.6.2-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.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for newt_agent_mesh-0.6.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1b6c66b78182d0123808bc22ae54e45901dcd67a23b01dcc959fc02ddb32c9d2
MD5 4574a8a1f70c6c495c2e3879ed65c52a
BLAKE2b-256 8f283c8b4a1ceceb7b968430bb88d851f2ca62e15fa80ee6afca76f07dba283d

See more details on using hashes here.

Provenance

The following attestation bundles were made for newt_agent_mesh-0.6.2-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.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for newt_agent_mesh-0.6.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1bbc93a0a7be94e79a369f7b625fb53edd1d7d56c0ecc2480e28b5790ebe7a80
MD5 8a0ac7a03521254da211102e7c254e69
BLAKE2b-256 146b691fb368614b56d21cd3a8ce7d62bae63a194f37cdf376085ea925209bd1

See more details on using hashes here.

Provenance

The following attestation bundles were made for newt_agent_mesh-0.6.2-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.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for newt_agent_mesh-0.6.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 45063b971962e3d79a819110eba412d04a78e16a807b9b9d936deef3120d38c2
MD5 3563aba8e2cbac52770ada9059748532
BLAKE2b-256 a751e1279181c4107aa4f6311998fcad46b5f3518265ae3c66f30779db151183

See more details on using hashes here.

Provenance

The following attestation bundles were made for newt_agent_mesh-0.6.2-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.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for newt_agent_mesh-0.6.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 33453646b66e502e2d3029a41ccc5eff65761cfc30b7f961313faf55ecfde549
MD5 71a80034a45daab4882daf3d119801a5
BLAKE2b-256 b5b44913eb06f3064ced8479bb4da6d093ed44da60df009c15e60e416189ad01

See more details on using hashes here.

Provenance

The following attestation bundles were made for newt_agent_mesh-0.6.2-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.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for newt_agent_mesh-0.6.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6cdbf8405f990d6ad36a0babe789ac153bd95cfa214e76cb9993178b111be739
MD5 a00b1b1a5e3d687299b7c3d7ba69b569
BLAKE2b-256 d1f4339763beb38b0be8dd8e5d07225d5607bd2c7e9a540a573746aad3192590

See more details on using hashes here.

Provenance

The following attestation bundles were made for newt_agent_mesh-0.6.2-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.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for newt_agent_mesh-0.6.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 47b3767614fbb99710b78f0dbc4b67e31ce344dd67568b7d5e2c959386b0b4fc
MD5 d40c3c3a6fd273a3fc5ef68c9edb396f
BLAKE2b-256 2b0b29fe812b3710e861c48003ddce66fe145e4f040777428ebc45d903976394

See more details on using hashes here.

Provenance

The following attestation bundles were made for newt_agent_mesh-0.6.2-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.2-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for newt_agent_mesh-0.6.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 186dadc08e29649d5394cef9968806312562b0f9e9a8e259eb0cf3822d10a779
MD5 5dd5d74d35facb8a51834be73774bd57
BLAKE2b-256 50d5ce07ff3de4c3708f1365cb913527433e41525b0097b85872c5b40383b98e

See more details on using hashes here.

Provenance

The following attestation bundles were made for newt_agent_mesh-0.6.2-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