Skip to main content

Python SDK for OpenAgentIO — ACP-compatible Envelope protocol on top of NATS / asyncio.

Project description

openagentio (Python SDK)

ACP-compatible Envelope protocol on top of NATS / asyncio. The protocol is shared with the Go SDK at the repo root; transport layers are implemented independently per language.

v0.2 skeleton — feature-equivalent surface to Go v0.1.

Layout

sdk/python/
├── pyproject.toml
├── src/openagentio/
│   ├── event/          # Envelope dataclass, event-type constants, payload shapes
│   ├── codec/          # JSON codec
│   ├── transport/      # base ABC + InMemoryDriver + NATSDriver
│   └── bus/            # Bus, Stream, StreamWriter, subject layout
├── tests/              # pytest, pytest-asyncio
└── examples/
    └── echo_agent.py

Install (development)

cd sdk/python
python3.11 -m venv .venv          # already done in this repo
.venv/bin/pip install -e ".[dev]"

Run tests

.venv/bin/pytest                   # unit tests (in-memory transport)
AFB_NATS_URL=nats://localhost:4222 .venv/bin/pytest tests/test_nats_integration.py

The NATS integration tests are gated on the AFB_NATS_URL env var. Start a local broker first, e.g. nats-server -p 4222.

Example

import asyncio
from openagentio import Bus, InMemoryDriver

async def main() -> None:
    bus = Bus(agent_id="echo", transport=InMemoryDriver())
    await bus.connect()

    async def echo(env):
        return env.payload_json()

    await bus.handle_invoke("echo", echo)
    resp = await bus.invoke("echo", {"msg": "hello"})
    print(resp.event_type, resp.payload_json())
    await bus.close()

asyncio.run(main())

See examples/echo_agent.py for a runnable version that mirrors examples/echo-agent/main.go from the Go SDK.

Protocol

The wire format is shared with the Go SDK:

  • spec_version = "acp/1.0", schema_version = 1
  • UUIDv7 event_id (RFC 9562) with UUIDv4 fallback
  • Subject layout acp.v1.events.<event_type> and acp.v1.invoke.<target> (with optional <tenant> segment)
  • Envelopes published by Go can be decoded in Python and vice versa; the golden tests in tests/test_envelope.py use shared sample envelopes from <repo>/schema/samples/.

Status

Surface Status
Envelope (v0.1) ✅ wire-compatible
In-memory transport
NATS transport ✅ (nats-py)
Pub / Sub
Invoke / Reply
Stream Invoke
Middleware framework ⏭ v0.3
JetStream ⏭ v0.3
Sync wrapper ⏭ v0.3

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

openagentio-0.2.0a2.tar.gz (63.0 kB view details)

Uploaded Source

Built Distribution

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

openagentio-0.2.0a2-py3-none-any.whl (46.3 kB view details)

Uploaded Python 3

File details

Details for the file openagentio-0.2.0a2.tar.gz.

File metadata

  • Download URL: openagentio-0.2.0a2.tar.gz
  • Upload date:
  • Size: 63.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for openagentio-0.2.0a2.tar.gz
Algorithm Hash digest
SHA256 f335d616f6e721fbcd63e2a21aa31a1d52d12f50f27c9fbb4bdf10c9c1eaa234
MD5 f136cadf9e405143e90279bcad42fe21
BLAKE2b-256 c1ce55f426c62e7e6e93e41b3a0600b35a0c5d6ec23efc7add676517cc6c80f7

See more details on using hashes here.

File details

Details for the file openagentio-0.2.0a2-py3-none-any.whl.

File metadata

  • Download URL: openagentio-0.2.0a2-py3-none-any.whl
  • Upload date:
  • Size: 46.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for openagentio-0.2.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 1e15ffd13e08e485db7da5b649eb73dc0d068b20ac312fa8a2dfa727a69abd18
MD5 a89fb9ca508889e2aeb1b7b84c7c2466
BLAKE2b-256 907309fdf88e472ac0a23001a8a65adaf5a38ba5a90d877730b8f9f91390e1f7

See more details on using hashes here.

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