Skip to main content
Create an agent that categorizes and organizes a messy folder.

Create your Agent

Save the following code as sorting_hat.py:
sorting_hat.py

Run your Agent

1

Set up your virtual environment

2

Install dependencies

3

Export your OpenAI API key

Don’t have one? Get a key from platform.openai.com
4

Run your Agent

Run your Agent as a Service

The code above is an ad-hoc Python script. If we need our agent to do anything useful, we need to run it as a service. We should also:
  1. Add session storage, so we can have a conversation with our agent. Agno automatically manages session read, write and context injection for you.
  2. Add memory, so our agent learns from usage patterns. Agno automatically handles memory management and exposes an update_user_memory tool to the agent.
Save the following code as workbench.py:
workbench.py
Install new dependencies and run your Agent as a Service:
1

Install new dependencies

2

Run your service

The __main__ block calls agent_os.serve(), which starts a uvicorn server with hot reload.
3

Confirm server is running

Your AgentOS is now running at http://localhost:7777.Open http://localhost:7777/docs to view the API docs.
20 lines of code and you have:
  • A stateful agent served as a production API
  • Session storage and conversation history
  • Tracing on every run
  • Per-session isolation, with JWT-based RBAC available for multi-user isolation
No third-party services required.

Give your Agent a UI

The code above runs our agent as a service using AgentOS. AgentOS is a FastAPI-based runtime that serves agents and related operations as REST APIs. AgentOS also comes with a UI, available at: os.agno.com. It connects directly from your browser to the running API. Use it to test, monitor, and manage your agents in real time.
  1. Open os.agno.com and sign in.
  2. Click “Connect OS”
  3. Select “Local”, enter your endpoint URL (default: http://localhost:7777), name it “Local AgentOS”, and click “Connect”.
Click on Chat, and ask:
Click Sessions or Traces in the sidebar to inspect stored conversations.
All session data is stored in your local database. No data leaves your system.

Next Steps