Python SDK
An asyncio Peer with the whole protocol inside, and no required dependencies.
The Python SDK is agentwireprotocol/python-sdk, package awp. A Peer listens and connects, sends messages in threads, and delivers what arrives as events, with everything the protocol asks for inside: resume with an outbox on disk, acks, dedup by id, blobs in chunks, grants and introductions, ping/pong, reconnection with backoff.
Python 3.11 or later, asyncio, no required dependencies. Ed25519 uses the cryptography package when it is installed and a pure-Python implementation otherwise.
pip install awp # or: pip install "awp[crypto]"A peer in a few lines
import asyncio
import awp
async def main():
async with awp.Peer("~/.mybot", name="mybot@builder") as peer:
address = await peer.listen("tailcat") # or "tcp:127.0.0.1:7000", "unix:/tmp/awp.sock"
print("share this:", address)
key = await peer.connect("tc...") # an address shared out of band
peer.send(key, "Please run make test at a1b2c3.", subject="Run the suite")
async for event in peer.events():
match event:
case awp.Message():
print(f"{event.peer}: {event.text}")
case awp.State():
print(f"{event.peer} is {event.state} in {event.thread}")
case awp.Blob():
print(f"file {event.name} at {event.path}")
asyncio.run(main())API
The Peer’s constructor and methods, and every event with its fields.
Delegating a task
Connect, open a thread with the ask, wait for events, collect the result.
Taking a task
Listen, handle messages, report progress, send results and files back.
Files, grants, transports
Blobs, capabilities and requests, addresses and reconnection.
How it fits
Peer(state_dir) loads or creates the identity, and per peer an append-only outbox log of unacked messages, an inbox log of received ids and blob progress, the threads and the grants. kill -9 at any moment loses nothing. listen takes tcp:, unix: or tailcat, a WireGuard tunnel through the tailcat CLI with an address any peer can reach. connect returns the peer’s key after the handshake and keeps dialing with backoff, capped at a minute, whenever there is unfinished business. send never fails because the peer is away; wait_ack waits for the ack.
The SDK grew out of the independent Python peer that the reference implementation uses for interop tests, so it has been checked against the Go implementation since the first draft of the spec.
Conformance
pytest in the SDK’s repository runs a two-peer conversation with states, a reply, a multi-chunk blob, grants and bye; queued delivery across a restart; the driver’s thirty tests; and, with AWP_BIN set, the protocol’s conformance suite against a Peer, both listening and dialing.