Skip to main content

Python agent-host SDK for the Synadia Agent Protocol for NATS — register and serve spec-compliant agents over NATS

Project description

synadia-ai-agent-service

Python agent-host SDK for the Synadia Agent Protocol for NATS. Embed AgentService in a Python agent harness (Hermes-style, claude-code, openclaw, pi, …) to register a spec-compliant agent on a NATS bus.

Calling agents (rather than hosting them)? → use the sibling synadia-ai-agents package (from synadia_ai.agents import Agents, …). This package depends on it for the shared wire primitives.

Install

From a checkout (no published wheel yet):

uv pip install -e ../../client-sdk/python
uv pip install -e .

When both packages are on PyPI, plain pip install synadia-ai-agent-service will pull synadia-ai-agents>=0.6 automatically.

Quickstart — host an agent

import asyncio
import nats
from synadia_ai.agents import Envelope                       # shared wire types
from synadia_ai.agent_service import AgentService, PromptStream

async def echo(envelope: Envelope, stream: PromptStream) -> None:
    await stream.send(f"echo: {envelope.prompt}")

async def main() -> None:
    nc = await nats.connect(servers="nats://127.0.0.1:4222")
    service = AgentService(
        agent="demo",            # your harness identifier (§2: lowercase + hyphens)
        owner="alice",           # operator / account (§2)
        session_name="worker-1", # 5th subject token / session this instance serves
        nc=nc,
        description="demo echo agent",
    )
    service.on_prompt(echo)
    await service.start()
    try:
        await asyncio.Event().wait()   # run until Ctrl-C
    finally:
        await service.stop()
        await nc.close()

asyncio.run(main())

A spec-compliant runnable echo agent ships at examples/_reference_agent.py — used both as the test harness for the client-side numbered demos in ../../client-sdk/python/examples/ and as the wire-compat counterparty for cross-SDK interop.

Where things live

  • This package — synadia_ai.agent_service: AgentService, PromptStream, PromptHandler, the heartbeat publisher loop, the status endpoint handler, and the reference agent.
  • Sibling package — synadia_ai.agents (the client SDK): the shared wire primitives (Envelope, Attachment, HeartbeatPayload, AgentSubject, error classes, discovery constants, load_context_options, parse_nats_url).

Documentation

Development

uv sync
uv run ruff check . && uv run ruff format --check . && uv run mypy src tests examples && uv run pytest

Integration tests spawn a real nats-server per session and record wire evidence under tests/_evidence/<test-nodeid>/. The local [tool.uv.sources] override resolves synadia-ai-agents to the sibling client-sdk checkout, so no PyPI publish is required for CI to pass.

License

Apache-2.0. See LICENSE.

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

synadia_ai_agent_service-0.4.1.tar.gz (85.5 kB view details)

Uploaded Source

Built Distribution

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

synadia_ai_agent_service-0.4.1-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file synadia_ai_agent_service-0.4.1.tar.gz.

File metadata

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

File hashes

Hashes for synadia_ai_agent_service-0.4.1.tar.gz
Algorithm Hash digest
SHA256 1562a89b26d8d1fb89f76b552dda950bce602ba8506c1aeef0e093e67ed96f9a
MD5 7f3a016d119b0c5c729acd7e06da44f8
BLAKE2b-256 6ceffe16db2dc1fa7d86c0d6cdc3f70ae1981eb73006077624e9bbd616210748

See more details on using hashes here.

Provenance

The following attestation bundles were made for synadia_ai_agent_service-0.4.1.tar.gz:

Publisher: release-python-agent-service.yml on synadia-ai/synadia-agents

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

File details

Details for the file synadia_ai_agent_service-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for synadia_ai_agent_service-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5ad9c4d88866eb3fe34a3deea130618996b0fb2e5227114f9fa37998f8084bac
MD5 0c8cba156633d9bf61b5f6586faa4ac0
BLAKE2b-256 165ea840c57d58e7fff402628680a6a115814675d76de1cf75b6e5db239a42d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for synadia_ai_agent_service-0.4.1-py3-none-any.whl:

Publisher: release-python-agent-service.yml on synadia-ai/synadia-agents

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