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

# Agent With Tools

> Combine server-side web search with a frontend haiku tool in an agent served over AG-UI.

```python agent_with_tools.py theme={null}
"""
Agent With Tools
================

Demonstrates agent with tools.
"""

from typing import List

from agno.agent.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.os import AgentOS
from agno.os.interfaces.agui import AGUI
from agno.tools import tool
from agno.tools.websearch import WebSearchTools

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


# Frontend Tools
@tool(external_execution=True)
def generate_haiku(
    english: List[str], japanese: List[str], image_names: List[str]
) -> str:
    """Generate a haiku in Japanese and English and display it in the frontend."""
    return "Haiku generated and displayed in frontend"


agent = Agent(
    model=OpenAIResponses(id="gpt-5.4"),
    tools=[
        WebSearchTools(),
        generate_haiku,
    ],
    description="You are a helpful AI assistant with backend and frontend tools. You can search the web and create haikus that render in the frontend.",
    instructions="""
    You are a versatile AI assistant with the following capabilities:

    **Tools (executed on server):**
    - Web search using DuckDuckGo for finding current information

    Always be helpful, creative, and use the most appropriate tool for each request!
    """,
    add_datetime_to_context=True,
    add_history_to_context=True,
    add_location_to_context=True,
    timezone_identifier="Etc/UTC",
    markdown=True,
    debug_mode=True,
)


# Setup your AgentOS app
agent_os = AgentOS(
    agents=[agent],
    interfaces=[AGUI(agent=agent)],
)
app = agent_os.get_app()


# ---------------------------------------------------------------------------
# Run Example
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    """Run your AgentOS.

    You can see the configuration and available apps at:
    http://localhost:9001/config

    Use Port 9001 to configure Dojo endpoint.
    """
    agent_os.serve(app="agent_with_tools:app", port=9001, reload=True)
```

## Run the Example

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

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U "agno[agui,os]" ddgs openai requests
    ```
  </Step>

  <Step title="Export your OpenAI API key">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export OPENAI_API_KEY="your_openai_api_key_here"
      ```

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

  <Step title="Run the example">
    Save the code above as `agent_with_tools.py`, then run:

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

  <Step title="Run Dojo">
    Follow the [AG-UI frontend setup](/agent-os/interfaces/ag-ui/introduction) to clone, build, and start Dojo. Configure its Agno endpoint for port `9001`, then use Dojo to execute the `generate_haiku` frontend tool.
  </Step>
</Steps>

Full source: [cookbook/05\_agent\_os/interfaces/agui/agent\_with\_tools.py](https://github.com/agno-agi/agno/blob/main/cookbook/05_agent_os/interfaces/agui/agent_with_tools.py)
