> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2-codex-docs-audit-20260719-0149.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Workflows

> Define a SurrealDB-backed research workflow with a team step, writer step, and Pydantic input schema.

```python workflows.py theme={null}
"""
Workflows
=========

Demonstrates workflows.
"""

from typing import List

from agno.agent.agent import Agent
from agno.models.anthropic import Claude
from agno.team.team import Team
from agno.tools.firecrawl import FirecrawlTools
from agno.tools.wikipedia import WikipediaTools
from agno.workflow.step import Step
from agno.workflow.workflow import Workflow
from db import db
from pydantic import BaseModel, Field

# ---------------------------------------------------------------------------
# Create Example
# ---------------------------------------------------------------------------


# ************* Input Schema *************
class ResearchTopic(BaseModel):
    """Structured research topic with specific requirements"""

    topic: str
    focus_areas: List[str] = Field(description="Specific areas to focus on")


# *******************************


# ************* Agents *************
wikipedia_agent = Agent(
    name="Wikipedia Agent",
    model=Claude(id="claude-sonnet-4-5"),
    role="Extract key insights and content from Wikipedia articles",
    tools=[WikipediaTools()],
)
search_agent = Agent(
    name="Search Agent",
    model=Claude(id="claude-sonnet-4-5"),
    role="Search the web for the latest news and trends using Firecrawl",
    tools=[FirecrawlTools()],
)
writer_agent = Agent(
    name="Writer Agent",
    model=Claude(id="claude-sonnet-4-5"),
    instructions=[
        "Write a detailed report on the provided topic and research content",
    ],
)
# *******************************


# ************* Team *************
research_team = Team(
    name="Research Team",
    model=Claude(id="claude-sonnet-4-5"),
    members=[wikipedia_agent, search_agent],
    instructions="Research tech topics from Wikipedia and the web",
)
# *******************************


# ************* Workflow Steps *************
research_step = Step(
    name="Research Step",
    team=research_team,
)

writer_step = Step(
    name="Writer Step",
    agent=writer_agent,
)
# *******************************


# ************* Workflow *************
research_workflow = Workflow(
    name="Research Workflow",
    description="Automated research on a topic",
    db=db,
    steps=[research_step, writer_step],
    input_schema=ResearchTopic,
)
# *******************************

# ---------------------------------------------------------------------------
# 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 anthropic firecrawl-py surrealdb wikipedia
    ```
  </Step>

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

      ```bash Windows theme={null}
      $Env:ANTHROPIC_API_KEY="your_anthropic_api_key_here"
      $Env:FIRECRAWL_API_KEY="your_firecrawl_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="Use the helper">
    This helper is imported by the SurrealDB AgentOS application.
  </Step>
</Steps>

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