# Search Agent

In this section, we will create a Search Agent Flow with the goal of encapsulating and automating search operations. This agent can integrate multiple built-in tools such as:

* Serp Google Search
* Tavily Search
* Wikipedia Search

By leveraging these tools, the Search Agent can automatically perform web searches based on user input and return structured results for downstream use or display.\
We will demonstrate this using both a **flow-based agent** and an **instruction-based agent**, allowing you to understand and compare their differences in structure and behavior.

## Implementation Method for Flow-based Agent

### Overview of Flow Structure

<figure><img src="https://4046886348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYf4L4Z4IuV1CQn3whQYb%2Fuploads%2FL3xlcW7ryPbobmHtnBoj%2F129518d38f83e91ce3bcf788de882338.png?alt=media&#x26;token=49497299-262d-411a-843c-eda82aca4e22" alt=""><figcaption></figcaption></figure>

### Tool Node

{% columns %}
{% column %}

<figure><img src="https://4046886348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYf4L4Z4IuV1CQn3whQYb%2Fuploads%2FWtxMSBQ6fz5CNA6qR21c%2Fc4eb6cdd661e2f84c723376970d96585.png?alt=media&#x26;token=c60ce497-e052-414b-bc4f-b9d7a290b3bc" alt=""><figcaption></figcaption></figure>
{% endcolumn %}

{% column %}

<figure><img src="https://4046886348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYf4L4Z4IuV1CQn3whQYb%2Fuploads%2FmmoMjjSQOVIeUxzdKRgt%2Fb8d739f0bcb38e84457c6019efa37ce9.png?alt=media&#x26;token=74e6692d-4306-4ba4-ad27-e7586b09f8da" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

Both built-in tools—Serp Google Search and Tavily Search—only require the user's input `query` to be passed in directly, without any additional processing or variable transformation.

### Answer Node

<figure><img src="https://4046886348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYf4L4Z4IuV1CQn3whQYb%2Fuploads%2FSBNhYtGqw8mZfc9SaU5L%2Fab3d4043ee25b783ac550bff2c091d06.png?alt=media&#x26;token=f910ec88-e10e-4079-bd1a-11bbc8fa9916" alt=""><figcaption></figcaption></figure>

The End Node receives results from both the Serp and Tavily search tools and combines them into a single unified output for the user.

## Implementation Method for Instruction-based Agent

Since search-related tools are relatively simple to use, an **Instruction-based Agent** can be employed. This agent is capable of autonomously selecting the appropriate search tool to retrieve relevant information and further processing the results before generating an output.

### Prompt

```
You will be given a user query.

Your task is to call both the Serp Google Search tool and the Tavily Search tool using this query as input.

Once both tools return results, summarize and consolidate the key information from both sources into a single, cohesive summary.

⚠️ Do NOT directly answer the user's question. Just provide a merged and well-organized summary of the retrieved information.

User Query: {{user_query}}

```

You can freely customize the prompt based on your specific needs to guide the agent in performing desired tasks or generating targeted outputs.

### Tools

<figure><img src="https://4046886348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYf4L4Z4IuV1CQn3whQYb%2Fuploads%2FPAAjrGdyo8AEPUviL9Rr%2F83dab3cada7c5612b41da2628e80701a.png?alt=media&#x26;token=3b9eabc6-2828-4007-9db3-fea604fe76ae" alt=""><figcaption></figcaption></figure>

Add both **Serp Google Search** and **Tavily Search** tools separately, and make sure they are enabled.
