Deep Search
Learn how to build a Deep Search autonomous agent
Overview
In this example, we will create a Deep Search agent that can search for information autonomously on the web and provide answers to user queries. The agent will use the built-in Latitude tools to search and read content from the Internet.
Prompts
Step-by-step guide
Related documentation:
Main prompt
First, we’ll start by creating a simple agent that takes a user input and can search information in the web using Latitude’s built-in search
and extract
tools.
Improving the agent workflow
Now, this agent works but it will fail in many cases! In most cases it will just return the first search result it finds, even if it is not even relevant.
Here are some improvements we can do to the agent:
- Ensure the agent can handle ambiguous queries by providing clarifying questions to the user.
- Make sure the agent can perform multiple iterations of research, and not just one.
- Fact-check the information it finds, and not just return the first search result.
- Include citations in the final answer.
Now we have a much more robust agent that can handle ambiguous queries, and will perform multiple iterations of research to find the most relevant information. It will also include citations in the final report.
Optimizing the agent
This agent works, but now it has too many responsibilities:
- It has to understand the user’s request.
- It has to perform the research.
- It has to fact-check the information it finds.
- It has to create a final report.
Not only this will affect the performance of the agent, but all those search queries will add too much context to the conversation, making it more expensive and slower.
To solve this, we can create a second agent which only task is to perform the heavy research, and just let the main agent to understand the user’s request and create the final report.
Let’s start by creating this researcher
subagent. This agent will use both latitude/search
and latitude/extract
built-in tools to perform the research, and will return a detailed report based on a question that the main agent will provide.
Now, we can modify the original agent to use this new researcher
agent to perform the research instead of the built-in tools.