agents.py
"""
Agents
======
Demonstrates agents.
"""
from textwrap import dedent
from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.tools.mcp import MCPTools
from db import db
# ---------------------------------------------------------------------------
# Create Example
# ---------------------------------------------------------------------------
# ************* Create Agno Assist *************
agno_assist = Agent(
name="Agno Assist",
model=Claude(id="claude-sonnet-4-5"),
db=db,
# Enable agentic memory
enable_agentic_memory=True,
# Add the previous session history to the context
add_history_to_context=True,
# Add the current date and time to the context
add_datetime_to_context=True,
# Enable markdown formatting
markdown=True,
# Add the Agno MCP server to the Agent
tools=[MCPTools(transport="streamable-http", url="https://docs.agno.com/mcp")],
description=dedent(
"""\
You are Agno Assist, an advanced AI Agent specializing in the Agno framework and the AgentOS.
Your goal is to help developers understand and effectively use Agno and the AgentOS by providing
explanations and working code examples."""
),
instructions=dedent(
"""\
Follow these steps to ensure the best possible response:
1. **Analyze the request**
- Determine if it requires a knowledge search or creating an Agno Agent.
- If you need to search the knowledge base, identify 1-3 key search terms related to Agno concepts.
- If you need to create an Agent, search your knowledge base for relevant concepts and use the example code as a guide.
- When the user asks for an Agent, they mean an Agno Agent.
- All concepts are related to Agno, so you can search your knowledge base for relevant information
After the analysis, determine if you need to create an Agno Agent.
2. **Agent Creation**
- Create a complete, working Agno Agent that users can run to demonstrate Agno's capabilities. For example:
```python
from agno.agent import Agent
from agno.tools.websearch import WebSearchTools
agent = Agent(tools=[WebSearchTools()])
# Perform a web search and capture the response
response = agent.run("What's happening in France?")
```
- Remember to:
* Use agent.run() and NOT agent.print_response()
* Build the complete Agno Agent implementation
* Include all necessary imports and setup
* Add comprehensive comments explaining the implementation
* Ensure all dependencies are listed
* Include error handling and best practices
* Add type hints and documentation
Key topics to cover:
- Agno Agents and their capabilities
- The AgentOS and its features
- Tool integration
- Model support and configuration
- Best practices and common patterns
- How to use the Agno MCP server
- How to use the AgentOS UI"""
),
)
# *******************************
# ---------------------------------------------------------------------------
# Run Example
# ---------------------------------------------------------------------------
if __name__ == "__main__":
raise SystemExit("This module is intended to be imported.")
db.py
"""
Db
==
Demonstrates db.
"""
from agno.db.surrealdb import SurrealDb
# ---------------------------------------------------------------------------
# Create Example
# ---------------------------------------------------------------------------
# ************* SurrealDB Config *************
SURREALDB_URL = "ws://localhost:8000"
SURREALDB_USER = "root"
SURREALDB_PASSWORD = "root"
SURREALDB_NAMESPACE = "agno"
SURREALDB_DATABASE = "agent_os_demo"
# *******************************
# ************* Create the SurrealDB instance *************
creds = {"username": SURREALDB_USER, "password": SURREALDB_PASSWORD}
db = SurrealDb(None, SURREALDB_URL, creds, SURREALDB_NAMESPACE, SURREALDB_DATABASE)
# *******************************
# ---------------------------------------------------------------------------
# Run Example
# ---------------------------------------------------------------------------
if __name__ == "__main__":
raise SystemExit("This module is intended to be imported.")
Run the Example
1
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
2
Install dependencies
uv pip install -U "agno[mcp]" anthropic surrealdb
3
Export your Anthropic API key
export ANTHROPIC_API_KEY="your_anthropic_api_key_here"
$Env:ANTHROPIC_API_KEY="your_anthropic_api_key_here"
4
Run SurrealDB
docker run -d --rm --name surrealdb --pull always -p 8000:8000 surrealdb/surrealdb:latest start --user root --pass root
5
Run the example
Save the code blocks above as
agents.py and db.py in the same directory, then run:python agents.py