Skip to main content

Wrap any agent function in a production-ready A2A server

Project description

pgns-agent

Express.js for A2A agents.

PyPI Python License

Wrap any agent function in a production-ready A2A-compatible server, powered by pgns.

from pgns_agent import AgentServer

agent = AgentServer("my-agent", "Echoes input")

@agent.on_task
async def handle(task):
    return {"echo": task.input}

agent.listen(3000)

Quickstart

Install:

pip install pgns-agent

Configure (optional — omit for local dev mode):

export PGNS_API_KEY="your-api-key"

Run:

python agent.py

Your agent is now live. Verify the agent card at http://localhost:3000/.well-known/agent.json.

Features

  • A2A protocol compliance — serves the standard Agent Card at /.well-known/agent.json
  • Auto-provisioning — registers an agent card and roost on the pgns relay at startup
  • Sync + async modes — handlers are always async, but the server can run standalone or embedded
  • SSE streaming — stream task progress updates to callers via Server-Sent Events
  • Task lifecyclesubmitted → working → completed/failed with full status tracking
  • Input-required flow — suspend a handler and request additional input from the caller
  • Local dev mode — run without a pgns API key for local development and testing

Three entry points

Standalone server — start a self-contained HTTP server:

agent.listen(3000)

Mount into an existing app — get a Starlette/ASGI application to compose with FastAPI, Starlette, or any ASGI framework:

app = agent.app()

Serverless handler — get the raw ASGI callable for Lambda, Cloud Functions, etc.:

handler = agent.handler()

Framework adapters

Adapters let you wire existing agent frameworks into pgns-agent with zero glue code.

LangChain / LangGraph

pip install pgns-agent-langchain
from pgns_agent import AgentServer
from pgns_agent.adapters import LangChainAdapter

agent = AgentServer("my-langchain-agent", "Runs a LangChain chain")
agent.use(LangChainAdapter(my_runnable))
agent.listen(3000)

OpenAI Agents SDK

pip install pgns-agent-openai

Claude Agent SDK

pip install pgns-agent-claude

CrewAI

pip install pgns-agent-crewai

Testing

Use the built-in test client for unit testing — no server required:

client = agent.test_client()
resp = client.send_task({"text": "hello"})
assert resp.status == "completed"
assert resp.result == {"echo": {"text": "hello"}}

Documentation

Full documentation is available at docs.pgns.io/libraries/pgns-agent.

License

Apache 2.0

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

pgns_agent-0.1.2.tar.gz (40.7 kB view details)

Uploaded Source

Built Distribution

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

pgns_agent-0.1.2-py3-none-any.whl (27.4 kB view details)

Uploaded Python 3

File details

Details for the file pgns_agent-0.1.2.tar.gz.

File metadata

  • Download URL: pgns_agent-0.1.2.tar.gz
  • Upload date:
  • Size: 40.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pgns_agent-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e8edf59f4e993f8aedbbc434deb79359942a0bd2ff47615f312d4e4c2628c391
MD5 82a46d91a55635a12d89618eeae051d6
BLAKE2b-256 1ca575d68255d7f1cc029306ed8b57fafee2f98f89d14cbe87a30852b0e564d0

See more details on using hashes here.

File details

Details for the file pgns_agent-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pgns_agent-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 27.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pgns_agent-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dec97b52d62824146f8b2f2b1f4fd418fa1efd2f812a11bb3c2fcba3d0d76e12
MD5 46950b59df12880e89d416040efd37b3
BLAKE2b-256 78a029ff9666b9207172a8119566b425b0146cf87be9d37a3c81cd1c8ff7509e

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