Use this file to discover all available pages before exploring further.
A WorkflowFactory produces a fresh Workflow for each request. Register it in AgentOS(workflows=[...]) alongside any prototype workflows.
basic_workflow_factory.py
from agno.agent import Agentfrom agno.db.postgres import PostgresDbfrom agno.factory import RequestContextfrom agno.models.openai import OpenAIResponsesfrom agno.os import AgentOSfrom agno.workflow import Step, Workflow, WorkflowFactorydb = PostgresDb(db_url="postgresql+psycopg://ai:ai@localhost:5532/ai")def build_content_pipeline(ctx: RequestContext) -> Workflow: user_id = ctx.user_id or "anonymous" drafter = Agent( name="Drafter", model=OpenAIResponses(id="gpt-5.4"), instructions=( f"You are a content drafter for tenant {user_id}. " "Write a first draft based on the topic. Keep it focused and concise." ), ) editor = Agent( name="Editor", model=OpenAIResponses(id="gpt-5.4"), instructions=( f"You are an editor for tenant {user_id}. " "Review the draft for clarity, grammar, and structure. Output the final version." ), ) return Workflow( name="Content Pipeline", description="Draft then edit content", db=db, steps=[ Step(name="draft", description="Write the first draft", agent=drafter), Step(name="edit", description="Edit and finalize", agent=editor), ], )content_pipeline_factory = WorkflowFactory( id="content-pipeline", db=db, factory=build_content_pipeline, name="Content Pipeline", description="Builds a draft-then-edit content workflow per tenant.",)agent_os = AgentOS(workflows=[content_pipeline_factory])app = agent_os.get_app()if __name__ == "__main__": agent_os.serve(app="basic_workflow_factory:app", port=7777, reload=True)
Run the workflow like any other workflow:
curl -X POST http://localhost:7777/workflows/content-pipeline/runs \ -F 'message=Write a blog post about sustainable energy' \ -F 'user_id=tenant_42' \ -F 'stream=false'
See the Factories reference for the full constructor signature and parameter list.
The tier claim is read from verified middleware, so the tier cannot be changed by the request body. See Authorization From Verified Context for the trust model and JWT Role Factory for an end-to-end JWT example.
Raise FactoryPermissionError from inside the factory to reject unauthorized callers with HTTP 403. AgentOS raises FactoryValidationError (400) automatically when factory_input fails input_schema validation.
from agno.factory import FactoryPermissionErrordef build_pipeline(ctx: RequestContext) -> Workflow: if "workflows:run" not in ctx.trusted.scopes: raise FactoryPermissionError("Missing 'workflows:run' scope") ...
See the Factories reference for the full exception hierarchy and the post-resolve behavior.
GET /workflows/{id}/runs/{run_id} and GET /workflows/{id}/runs re-invoke the factory because the workflow has to be reconstructed to read its session state. Pass factory_input as a query parameter to drive the rebuild: