Skip to main content

agent-phone (Python)

CI Spec License

Idiomatic Python port of @p-vbordei/agent-phone. Minimal sync RPC between two AI agents — Noise-XK handshake over WebSocket, DID-bound peer identity, framed binary transport, self-custody keys. Wire-format-identical with the TS reference: the C4 hex vector matches byte-for-byte.

What's in the box

  • Noise-XK handshake (X25519 + ChaCha20Poly1305 + BLAKE2s + HKDF)
  • DID-bound peer identity (Ed25519 → X25519 via SHA-512 + RFC 7748 clamp)
  • Length-prefixed frame transport (ChaChaPoly seal/open)
  • WebSocket client + server (websockets asyncio)
  • Session lifecycle (connect, call, stream, close)
  • Backpressure (credit-based streaming with auto-refresh at the half-mark)

Install

pip install agent-phone
# or, for development:
uv sync --extra dev

Quickstart

import asyncio
from agent_phone import (
    ClientOptions, ServerOptions, connect, create_server,
    encode_did_key, generate_key_pair,
)

async def main() -> None:
    resp, init = generate_key_pair(), generate_key_pair()
    resp_did = encode_did_key(resp.public_key)

    server = create_server(ServerOptions(
        did=resp_did, private_key=resp.private_key,
        handlers={"echo": lambda p: p},
    ))
    await server.listen(0, hostname="127.0.0.1")
    port = server.address().port

    client = await connect(ClientOptions(
        url=f"ws://127.0.0.1:{port}",
        did=encode_did_key(init.public_key),
        private_key=init.private_key,
        responder_did=resp_did,
    ))
    print(await client.call("echo", {"hi": 1}))  # {'hi': 1}
    await client.close()
    await server.close()

asyncio.run(main())
uv run python examples/quickstart.py
# server listening on 127.0.0.1:<port>
# noise-xk handshake complete; channel authenticated
# echo result  : {'hello': 'agent-phone'}
# closed cleanly

How it relates

Implementation Status Wire format
@p-vbordei/agent-phone (TypeScript) Reference source of truth
agent-phone (Python, this repo) Port byte-identical
agent-phone (Rust) Port byte-identical

Conformance

The v0.1 spec defines four conformance clauses; all four pass against the TS test suite.

  • C1 — Handshake DID-binding. Swap the responder's static mid-handshake → initiator aborts deterministically at message 2 (AEAD fails). tests/test_conformance.py::test_c1_handshake_did_binding.
  • C2 — Streaming backpressure. Server emits 10 000 chunks, client grants 8 at a time → outstanding chunks stay bounded; every chunk arrives in order. test_c2_streaming_backpressure.
  • C3 — Graceful cancel. Cancel mid-stream → server stops within one frame, session stays open for further RPCs. test_c3_graceful_cancel.
  • C4 — Frame determinism. Canonical envelope bytes match the TS hex vector byte-for-byte. test_c4_frame_determinism reads vectors/c4.json, which mirrors the TS suite.
uv run pytest -v
# 31 passed

Architecture

Module map, dependency choices (hand-rolled Noise XK on cryptography + manual X25519), Ed25519→X25519 derivation gotcha, byte-determinism invariants, and testing strategy: see docs/architecture.md.

Development

git clone https://github.com/p-vbordei/agent-phone-py
cd agent-phone-py
uv sync --extra dev
uv run pytest -v
uv run ruff check .

Contributions welcome — see CONTRIBUTING.md. Any change to noise.py, frame.py, or envelope.py must keep the C4 hex vector passing; that's the wire-format contract.

License

Apache-2.0 — see LICENSE.

Metadata

Release files for kindred-agent-phone 0.1.0

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

Source distribution (sdist)

Source distribution for kindred-agent-phone 0.1.0
File Size Uploaded Provenance
kindred_agent_phone-0.1.0.tar.gz 26.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for kindred-agent-phone 0.1.0
File Interpreter ABI Platform
kindred_agent_phone-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 46.1 kB

Release files / kindred_agent_phone-0.1.0.tar.gz

Download URL kindred_agent_phone-0.1.0.tar.gz
Size 26.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d6927b3a878b311918b24bc8ab1cbc0659cd21325a7b9b5df36173b128755302
BLAKE2b-256 checksum
How to use checksums
707981718ed9a15848606cb90dc128a5731325a766c07b62d73c2a8343ecaeaf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 21, 2026.

Transparency log

Release files / kindred_agent_phone-0.1.0-py3-none-any.whl

Download URL kindred_agent_phone-0.1.0-py3-none-any.whl
Size 19.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
547a2559ccdbb54ba717ad9f9f83335f23a5bc016060fac56673229f4ebfe394
BLAKE2b-256 checksum
How to use checksums
718e815813fd0d06d48f5c53c48ac83348bfabbd61f2436996dbb52d0e5331db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 21, 2026.

Transparency log

Security for kindred-agent-phone 0.1.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for kindred_agent_phone-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 21, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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