# Approach 1: Single Agent with a Defined Role

In this first approach, we’ll focus on setting up a single, goal-oriented agent using a “React Agent” model. This approach is best suited for simple, focused use cases where a single agent can handle the entire search and response process.

<figure><img src="/files/WZyLd8aztZorxHAGyCnf" alt=""><figcaption><p>Creating the searcher agent</p></figcaption></figure>

<figure><img src="/files/LesZy4U4NkN6WxJqlLcU" alt=""><figcaption><p>Configuring the searcher agent</p></figcaption></figure>

### Step 1: Selecting the Agent and Setting Up the Environment

We start by selecting a React Agent, a popular choice for single-agent tasks due to its adaptability and efficiency. The setup will involve:

* Defining the agent’s role clearly.
* Configuring the necessary tools for the agent, such as a search tool.
* Testing and deploying the agent workflow.

Here’s an example configuration:

* **Role:** To retrieve accurate information in response to a user’s query
* **Agent:** React Agent
* **Tool:** SERP (Search Engine Results Page) tool for external search

<figure><img src="/files/xgrKUNWJ6J2TuTcHkOVF" alt=""><figcaption></figcaption></figure>

### Step 2: Defining the Agent’s Role

Once the agent is selected, we set a clear, specific role that guides the agent's behavior. In this case, the agent’s role could be as simple as:

> You are an expert AI assistant focused on refining user queries, conducting thorough searches, and delivering well-sourced answers. Your goal is to help users by clarifying their questions, performing detailed searches using available tools, and presenting accurate responses with proper citations and direct links, using markdown. Prioritize accuracy, clarity, and credibility in all answers. If information is conflicting or unclear, note this and suggest further research options.

<figure><img src="/files/6vAuykYDLZkUMSw32FPW" alt=""><figcaption></figcaption></figure>

### Step 3: Testing the Workflow

Testing is an essential part of the setup process. After connecting the nodes, we must test the endpoint to verify that:

1. The agent receives the query
2. The response is returned correctly

Using a test interface allows us to monitor the logs and refine the workflow as necessary.

<figure><img src="/files/YTvHR0E94rS6ozHi72Wl" alt=""><figcaption></figcaption></figure>

We select a react agent, we add a serp tool for searching we craft the role  for agent for example like here: """ role agent", then we connect inputs between nodes and outputs. Firstly we are going to test this workflow by testing endpoint and view how it works

### Step 4: Deploying the Workflow

After testing, we deploy the workflow, making it accessible via API or any compatible UI. This deployment allows integration with applications built in Python, Java, C, or any other language that supports HTTP requests.

We can continue testing in the UI to observe real-time responses and logs, ensuring smooth and reliable operation.

<figure><img src="/files/mRi5xotibqFE9drHyOqe" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.getdynamiq.ai/examples/building-a-search-assistant/approach-1-single-agent-with-a-defined-role.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
