AgentOS Runtime

Configure the FastAPI runtime that serves your agents, teams, and workflows.

AgentOS serves agents, teams, and workflows through a FastAPI application you own and host. The runtime provides execution APIs, persistent state, authorization, tracing, and operational endpoints.

agent_os.py
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses
from agno.os import AgentOS

db = SqliteDb(db_file="tmp/agentos.db")

assistant = Agent(
    id="assistant",
    model=OpenAIResponses(id="gpt-5.4"),
)

agent_os = AgentOS(
    id="product-agent-os",
    agents=[assistant],
    db=db,
    tracing=True,
)

app = agent_os.get_app()

if __name__ == "__main__":
    agent_os.serve(app="agent_os:app", reload=True)

The AgentOS database becomes the default for local agents, teams, and workflows that do not define their own database. In this example it stores the agent's sessions and the runtime's traces.

Choose Runtime Capabilities

Add capabilities as the application needs them:

RequirementAgentOS configurationGuide
Serve agents, teams, and workflowsagents, teams, workflowsUsing the API
Use a shared default databasedbDatabase
Require JWT authorizationauthorization=TrueAuthorization
Store execution tracestracing=TrueTracing
Expose an MCP servermcp=TrueAgentOS as MCP Server
Serve bounded public componentspublic=PublicSurface(...)Public Surface
Persist accepted background jobsqueue=QueueConfig(durable=True)Durable queue
Mount product and messaging interfacesinterfaces=[...]Interfaces
Run cron schedulesscheduler=TrueScheduler
Extend an existing FastAPI applicationbase_app=appBring Your Own FastAPI App

Database Behavior

ConfigurationBehavior
Set db on AgentOSComponents without a database inherit the AgentOS database
Set a database on a componentThat component keeps its own database
Set db and tracing=TrueAgentOS stores all traces in the AgentOS database
Omit db with tracing=TrueAgentOS uses the first component database it discovers
Keep auto_provision_dbs=TrueAgentOS creates the required tables when the application starts

Set an explicit AgentOS database when the runtime manages several component databases. This gives tracing, service accounts, and scheduled jobs a predictable store.

Startup and shutdown

get_app() assembles the configured FastAPI routes. When the application starts, AgentOS combines your lifespan with the lifespans needed by the base app, MCP clients and server, databases, scheduler, and durable workers. Shutdown exits those managed lifespans and releases their resources.

Use an application lifespan for initialization your service owns, such as preparing a published-page Knowledge store. Durable jobs require the queue to be enabled; database persistence alone does not make an in-process background task survive a restart. See multiple replicas for shared cancellation and event delivery.

Runtime Methods

MethodPurpose
get_app()Build and return the configured FastAPI application
serve()Start the application with Uvicorn
get_routes()Return the FastAPI routes mounted by AgentOS
resync(app)Discover, initialize, and configure agents, teams, workflows, databases, and knowledge on an existing app

Host and Port

serve() reads AGENT_OS_HOST and AGENT_OS_PORT. Environment variables take precedence over method arguments.

SettingDefault
AGENT_OS_HOSTlocalhost
AGENT_OS_PORT7777
export AGENT_OS_HOST=0.0.0.0
export AGENT_OS_PORT=8000
python agent_os.py

Next Steps

TaskGuide
Call the runtime from an applicationUsing the API
Add AgentOS to an existing backendBring Your Own FastAPI App
Configure the Control Plane experienceAgentOS Configuration
Review every constructor parameterAgentOS class reference