---
highlights: >
    The Agent component enables tool-calling functionality with provider-agnostic chat model support and can be used as a standalone component or within a pipeline.

    ```python
    from haystack.components.agents import Agent
    from haystack.components.generators.chat import OpenAIChatGenerator
    from haystack.components.websearch import SerperDevWebSearch
    from haystack.dataclasses import ChatMessage
    from haystack.tools.component_tool import ComponentTool

    web_tool = ComponentTool(
        component=SerperDevWebSearch(),
    )

    agent = Agent(
        chat_generator=OpenAIChatGenerator(),
        tools=[web_tool],
        exit_condition="text",
    )

    result = agent.run(
        messages=[ChatMessage.from_user("Find information about Haystack")]
    )
    ```
