The Naylence Agent SDK is the official toolkit for building agents and clients on the Naylence Agentic Fabric. It gives you a clean, typed, async-first API for composing tasks, streaming results, and wiring agents together—locally or across a distributed fabric.
If you're new to Naylence, start here. For lower‑level transport/fabric internals, see naylence‑runtime.
BaseAgent (one-shot) or BackgroundTaskAgent (long‑running/streaming) and focus on your logic.Task, Message, Artifact, and JSON‑RPC A2A operations.Agent.broadcast, Agent.run_many).Agent.remote_* helpers.create_agent_router) and /agent.json metadata endpoint.naylence‑advanced‑security add‑on.pip install naylence-agent-sdk
Python 3.12+ is required.
import asyncio
from typing import Any
from naylence.fame.core import FameFabric
from naylence.agent import Agent, BaseAgent
class EchoAgent(BaseAgent):
async def run_task(self, payload: Any, id: Any) -> Any:
return payload
async def main():
async with FameFabric.create() as fabric:
address = await fabric.serve(EchoAgent())
echo = Agent.remote_by_address(address)
print(await echo.run_task("Hello, world!", None))
asyncio.run(main())
For a gentle, runnable tour—from single‑process to distributed orchestration—use the Examples repo: https://github.com/naylence/naylence-examples-python.
Agents & tasks
run_task(payload, id) for simple one‑shot work, or override start_task(...)/get_task_status(...) for background jobs.Message.parts carries either text (TextPart) or structured data (DataPart).TaskStatusUpdateEvent and TaskArtifactUpdateEvent until terminal (COMPLETED/FAILED/CANCELED).Remote proxies
Agent.remote_by_address("[email protected]") to call a known address.Agent.remote_by_capabilities(["agent"]) to call by capability (fabric does resolution).Streaming & cancel
subscribe_to_task_updates(...) yields status/artifacts live.cancel_task(...) requests cooperative cancellation when supported by the agent.RPC operations
tasks/send, .../get, .../cancel, etc.) are provided for task lifecycle.FastAPI router
create_agent_router(agent) to expose a JSON‑RPC endpoint (default: /fame/v1/jsonrpc) and GET /agent.json to return an AgentCard.BaseAgent — great for synchronous/short tasks; the default fallback packages your return value into a Task(COMPLETED).BackgroundTaskAgent — best for long‑running/streaming work. You implement run_background_task(...); the base manages queues, TTLs, and end‑of‑stream.Both base classes include sensible defaults (poll‑based streaming, simple auth pass‑through). You can override any part of the lifecycle.
FameFabric.create() in tests or local scripts to host agents in‑process.To generate API documentation from source:
# Generate Markdown docs to docs/api/
poetry run docs-gen
# Or specify a custom output directory
poetry run docs-gen --out path/to/output
The generated docs are Markdown files compatible with Nextra and other documentation systems.
The SDK runs on the Naylence fabric’s security profiles:
naylence‑advanced‑security package.See repo links below for the advanced add‑on and images that bundle it.
Docker images:
naylence/agent-sdk-pythonnaylence/agent-sdk-adv-python (includes naylence-advanced-security; BSL-licensed add-on)Content type
Image
Digest
sha256:31a017a5f…
Size
64.8 MB
Last updated
5 months ago
docker pull naylence/agent-sdk-python