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 agnt5The 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
| API | Use it to |
|---|---|
@function | Define a function: one unit of work with retries and tracing |
@workflow | Define a workflow that runs steps with ctx.step() |
Agent | Run an agent loop over a language model |
@tool | Give an agent a tool it can call |
agnt5.lm | Call a language model directly |
Worker | Register components and connect them to AGNT5 |
Client, AsyncClient | Run 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
- Getting startedCreate a Python AGNT5 project, run it locally with agnt5 dev, and deploy it
- FunctionsDefine functions with @function, configure retries, and call them from workflows
- WorkflowsDefine workflows with @workflow, checkpoint steps, run work concurrently, keep state, and schedule runs
- Context APIThe FunctionContext and WorkflowContext objects Python handlers receive — run details, steps, state, waits, logging, and progress
- AgentsCreate agents with Agent, run or stream them, hand off between agents, and use agents as tools
- ToolsDefine tools with @tool, give agents a schema from type hints, and run tools on their own
- LMCall language models directly with agnt5.lm — generate, stream, structured output, reasoning effort, and prompts
- WorkerStart a Python worker, register components and agents, and connect them to AGNT5
- ClientRun components, follow runs, run batches, and evaluate components from your own Python code