> ## Documentation Index
> Fetch the complete documentation index at: https://phidatainc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Agents

> Define Agno Assist with agentic memory, the Agno MCP server, and SurrealDB session storage.

````python agents.py theme={null}
"""
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.")
````

The example imports this helper module from the same directory:

```python db.py theme={null}
"""
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

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U "agno[mcp]" anthropic surrealdb
    ```
  </Step>

  <Step title="Export your Anthropic API key">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export ANTHROPIC_API_KEY="your_anthropic_api_key_here"
      ```

      ```bash Windows theme={null}
      $Env:ANTHROPIC_API_KEY="your_anthropic_api_key_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Run SurrealDB">
    ```bash theme={null}
    docker run -d --rm --name surrealdb --pull always -p 8000:8000 surrealdb/surrealdb:latest start --user root --pass root
    ```
  </Step>

  <Step title="Run the example">
    Save the code blocks above as `agents.py` and `db.py` in the same directory, then run:

    ```bash theme={null}
    python agents.py
    ```
  </Step>
</Steps>

Full source: [cookbook/05\_agent\_os/dbs/surreal\_db/agents.py](https://github.com/agno-agi/agno/blob/main/cookbook/05_agent_os/dbs/surreal_db/agents.py)
