Skip to content

Python SDKAGNT5 Python SDK

AGNT5 Python SDK

Build durable functions, workflows, and AI agents in Python with the agnt5 package

The Python SDK (agnt5) lets you define functions, workflows, agents, and tools with decorators and classes, and run them on a worker that connects to AGNT5. Every step a workflow checkpoints survives worker restarts, and every run is traced.

Installation

pip install agnt5

The SDK runs on Python 3.11 or later. These pages describe version 0.14.4.

Quick example

A function does one unit of work, a workflow runs functions as checkpointed steps, and a worker registers them with AGNT5:

import asyncio

from agnt5 import FunctionContext, Worker, WorkflowContext, function, workflow


@function
async def greet(ctx: FunctionContext, name: str) -> str:
    return f"Hello, {name}!"


@workflow
async def welcome(ctx: WorkflowContext, name: str) -> dict:
    message = await ctx.step(greet, name)
    return {"message": message}


async def main() -> None:
    worker = Worker(service_name="quickstart", workflows=[welcome])
    await worker.run()


if __name__ == "__main__":
    asyncio.run(main())

Run it with agnt5 dev, then trigger the workflow:

agnt5 run welcome --type workflow --input '{"name": "Ada"}'

What’s in the SDK

APIUse it to
@functionDefine a function: one unit of work with retries and tracing
@workflowDefine a workflow that runs steps with ctx.step()
AgentRun an agent loop over a language model
@toolGive an agent a tool it can call
agnt5.lmCall a language model directly
WorkerRegister components and connect them to AGNT5
Client, AsyncClientRun components and evaluate them from your own code

The agnt5.serverless module serves components as a serverless endpoint.

Next steps

  • Getting started: create a project, run it locally, and deploy it.
  • Build with AGNT5: guides for functions, workflows, agents, tools, and more, with Python examples on every page.

Modules