What You’ll Build
A stateful, tool-using agent that:- Connects to the Agno documentation via MCP
- Remembers conversation context across sessions
- Streams responses in real time
- Runs as a production API
- Integrates with the AgentOS UI
Prerequisites
Before you begin, make sure you have:- Python 3.7 or higher
- An Anthropic API key (get one here)
Step 1: Create Your Agent
Create a new file calledagno_assist.py:
agno_assist.py
This example uses SQLite for simplicity. For production, use PostgreSQL. See the Installation guide for database setup.
Step 2: Set Your API Key
Export your Anthropic API key:Step 3: Run Your Agent
Start the AgentOS server usinguvx:
http://localhost:8000.
What's happening here?
What's happening here?
uvxruns the command with the specified dependencies without requiring a virtual environment--with "agno[os]"installs Agno with AgentOS dependencies (FastAPI, uvicorn, SQLAlchemy)--with anthropicinstalls the Anthropic SDK--with mcpinstalls MCP (Model Context Protocol) supportfastapi devstarts a development server with auto-reload
Step 4: Connect to AgentOS UI
Now let’s connect your agent to the AgentOS web interface:Open AgentOS
Visit os.agno.com and sign in
Configure connection
- Select “Local” to connect to a local AgentOS
- Enter your endpoint URL:
http://localhost:8000 - Name it “Local AgentOS”
- Click “Connect”
What You Just Built
In ~20 lines, you created:Stateful Agent
Remembers the last 3 conversation turns across sessions
Tool Integration
Can query Agno documentation via MCP
Production API
REST endpoints at http://localhost:8000
Real-time Streaming
Streams reasoning and responses as they’re generated
Per-user Isolation
Each user gets their own session and memory
Native Tracing
Full observability of every agent interaction
Try It Programmatically
You can also call your agent directly in Python:Understanding the Code
Let’s break down each component:Agent Configuration
name- Identifies the agent in logs and UImodel- The LLM to use (Claude Sonnet 4.6 in this case)db- Where to store conversation history and statetools- Functions the agent can call (MCP integration here)add_history_to_context=True- Include previous turns in contextnum_history_runs=3- Remember last 3 conversation turnsmarkdown=True- Format responses as markdown
AgentOS Setup
agents- List of agents to expose via APItracing=True- Enable OpenTelemetry tracingget_app()- Returns a FastAPI application
Next Steps
Now that you have a working agent, explore more advanced features:Core Concepts
Learn about Agents, Teams, Workflows, and more
Add Memory
Give your agent long-term memory that persists
Add Knowledge
Connect your agent to vector databases and RAG
Production Setup
Deploy to production with PostgreSQL and monitoring
Common Issues
Port 8000 is already in use
Port 8000 is already in use
If port 8000 is already taken, specify a different port:
API key not found
API key not found
Make sure you’ve exported your API key in the same terminal session:Alternatively, create a
.env file:.env
Cannot connect to AgentOS UI
Cannot connect to AgentOS UI
Make sure:
- Your server is running at
http://localhost:8000 - You’re using the correct URL in the AgentOS connection dialog
- There are no firewall or network restrictions
You Can Use This Exact Same Architecture for Production
This isn’t just a demo. This is the same architecture used in production multi-agent systems:- Swap SQLite for PostgreSQL
- Add more agents and teams
- Deploy with Docker or Kubernetes
- Add authentication and authorization
- Scale horizontally