# DeepResearchTool

## `autogen.tools.experimental.DeepResearchTool`

```
DeepResearchTool(llm_config, max_web_steps=30)
```

Bases: `Tool`

A tool that delegates a web research task to the subteams of agents.

Initialize the DeepResearchTool.

| PARAMETER        | DESCRIPTION                                                                                                                                  |
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `llm_config`     | The LLM configuration.<br>**TYPE:**`(LLMConfig, dict[str, Any])`                                                                             |
| `max_web_steps`  | The maximum number of web steps. Defaults to 30.<br>**TYPE:**`int`**DEFAULT:**`30`                                                          |

Source code in `autogen/tools/experimental/deep_research/deep_research.py`

|                          |                          |
|--------------------------|--------------------------|
| ```                      | ```                      |
| def __init__(            | def __init__(            |
| self,                  | self,                  |
| llm_config: LLMConfig | llm_config: LLMConfig |
| | dict[str, Any],       | | dict[str, Any],       |
| max_web_steps: int = 30 | max_web_steps: int = 30 |
| ):                        | ):                        |
| """Initialize the DeepResearchTool.
| Args:                    | """Initialize the DeepResearchTool.
| llm_config (LLMConfig, dict[str, Any]): The LLM configuration.
| max_web_steps (int, optional): The maximum number of web steps. Defaults to 30. |
| """                    | self.llm_config = llm_config|
| self.summarizer_agent = ConversableAgent( | self.summarizer_agent = ConversableAgent( |
| name="SummarizerAgent",| name="SummarizerAgent",|
| system_message=(       | system_message=(       |
| "You are an agent with a task of answering the question provided by the user." | "You are an agent with a task of answering the question provided by the user."
| "First you need to split the question into subquestions by calling the 'split_question_and_answer_subquestions' method." | "First you need to split the question into subquestions by calling the 'split_question_and_answer_subquestions' method."
| "Then you need to synthesize the answers to the original question by combining the answers to the subquestions." | "Then you need to synthesize the answers to the original question by combining the answers to the subquestions."
| ),                      | ),                      |
| is_termination_msg=lambda x: ( | is_termination_msg=lambda x: ( |
| x.get("content", "") and x.get("content", "").startswith(self.ANSWER_CONFIRMED_PREFIX) | x.get("content", "") and x.get("content", "").startswith(self.ANSWER_CONFIRMED_PREFIX) |
| ),                      | ),                      |
| llm_config=llm_config, | llm_config=llm_config, |
| human_input_mode="NEVER", | human_input_mode="NEVER", |
| )                      | )                      |
| self.critic_agent = ConversableAgent( | self.critic_agent = ConversableAgent( |
| name="CriticAgent", | name="CriticAgent", |
| system_message=(       | system_message=(       |
| "You are a critic agent responsible for evaluating the answer provided by the summarizer agent. | "You are a critic agent responsible for evaluating the answer provided by the summarizer agent.
| Your task is to assess the quality of the answer based on its coherence, relevance, and completeness. | Your task is to assess the quality of the answer based on its coherence, relevance, and completeness.
| Provide constructive feedback on how the answer can be improved. | Provide constructive feedback on how the answer can be improved.
| If the answer is satisfactory, call the 'confirm_answer' method to end the task. | If the answer is satisfactory, call the 'confirm_answer' method to end the task.
| ),                      | ),                      |
| is_termination_msg=lambda x: ( | is_termination_msg=lambda x: ( |
| x.get("content", "") and x.get("content", "").startswith(self.ANSWER_CONFIRMED_PREFIX) | x.get("content", "") and x.get("content", "").startswith(self.ANSWER_CONFIRMED_PREFIX) |
| ),                      | ),                      |
| llm_config=llm_config, | llm_config=llm_config, |
| human_input_mode="NEVER", | human_input_mode="NEVER", |
| )                      | )                      |
| def delegate_research_task( | def delegate_research_task( |
| task: Annotated[str, "The task to perform a research on."], | task: Annotated[str, "The task to perform research on."] |
| llm_config: Annotated[LLMConfig | llm_config: Annotated[LLMConfig |
| | dict[str, Any], Depends(on(llm_config))], | | dict[str, Any], Depends(on(llm_config))], |
| max_web_steps: Annotated[int, Depends(on(max_web_steps))], | max_web_steps: Annotated[int, Depends(on(max_web_steps))], |
| ) -> str:            | ) -> str:            |
| """Delegate a research task to the agent. | """Delegate a research task to the agent.
| Args:                    | Args:                    |
| task (str): The task to perform research on. | task (str): The task to perform research on. |
| llm_config (LLMConfig, dict[str, Any]): The LLM configuration. | llm_config (LLMConfig, dict[str, Any]): The LLM configuration. |
| max_web_steps (int): The maximum number of web steps. | max_web_steps (int): The maximum number of web steps. |
| Returns:                | Returns:                |
| str: The answer to the research task. | str: The answer to the research task. |
| """                    | """                    |
| @self.summarizer_agent.register_for_execution() | @self.summarizer_agent.register_for_execution() |
| @self.critic_agent.register_for_llm(description="Call this method to confirm the final answer.") | @self.critic_agent.register_for_llm(description="Call this method to confirm the final answer.") |
| def confirm_summary(answer: str, reasoning: str) -> str: | def confirm_summary(answer: str, reasoning: str) -> str: |
| return f"{self.ANSWER_CONFIRMED_PREFIX}" + answer + "\nReasoning: " + reasoning | return f"{self.ANSWER_CONFIRMED_PREFIX}" + answer + "\nReasoning: " + reasoning |
| split_question_and_answer_subquestions = DeepResearchTool._get_split_question_and_answer_subquestions( | split_question_and_answer_subquestions = DeepResearchTool._get_split_question_and_answer_subquestions( |
| llm_config=llm_config, | llm_config=llm_config, |
| max_web_steps=max_web_steps, | max_web_steps=max_web_steps, |
| )                      | )                      |
| self.summarizer_agent.register_for_llm(description="Split the question into subquestions and get answers.")( | self.summarizer_agent.register_for_llm(description="Split the question into subquestions and get answers.")( |
| split_question_and_answer_subquestions | split_question_and_answer_subquestions |
| )                      | )                      |
| self.critic_agent.register_for_execution()(split_question_and_answer_subquestions) | self.critic_agent.register_for_execution()(split_question_and_answer_subquestions) |
| result = self.critic_agent.initiate_chat( | result = self.critic_agent.initiate_chat( |
| self.summarizer_agent, | self.summarizer_agent, |
| message="Please answer the following question: " + task, | message="Please answer the following question: " + task, |
| clear_history=False, | clear_history=False, |
| )                      | )                      |
| return result.summary    | return result.summary    |
| super().__init__(        | super().__init__(        |
| name=delegate_research_task.__name__, | name=delegate_research_task.__name__, |
| description="Delegate a research task to the deep research agent.", | description="Delegate a research task to the deep research agent.", |
| func_or_tool=delegate_research_task, | func_or_tool=delegate_research_task, |
| )                      | )                      |
| ```                     | ```                     |

### `name` property

```
name
```

### `description` property

```
description
```

### `func` property

```
func
```

### `tool_schema` property

```
tool_schema
```

Get the schema for the tool.

### `function_schema` property

```
function_schema
```

Get the schema for the function.

### `realtime_tool_schema` property

```
realtime_tool_schema
```

Get the schema for the tool.

### `ANSWER_CONFIRMED_PREFIX` class-attribute

```
ANSWER_CONFIRMED_PREFIX = 'Answer confirmed:'
```

### `llm_config` instance-attribute

```
llm_config = llm_config
```

### `summarizer_agent` instance-attribute

```
summarizer_agent = ConversableAgent(name='SummarizerAgent', system_message="You are an agent with a task of answering the question provided by the user.First you need to split the question into subquestions by calling the 'split_question_and_answer_subquestions' method.Then you need to synthesize the answers the original question by combining the answers to the subquestions.", is_termination_msg=lambda x: get('content', '') and startswith(ANSWER_CONFIRMED_PREFIX), llm_config=llm_config, human_input_mode='NEVER')
```

### `critic_agent` instance-attribute

```
critic_agent = ConversableAgent(name='CriticAgent', system_message="You are a critic agent responsible for evaluating the answer provided by the summarizer agent.Your task is to assess the quality of the answer based on its coherence, relevance, and completeness.Provide constructive feedback on how the answer can be improved.If the answer is satisfactory, call the 'confirm_answer' method to end the task.", is_termination_msg=lambda x: get('content', '') and startswith(ANSWER_CONFIRMED_PREFIX), llm_config=llm_config, human_input_mode='NEVER')
```

### `SUBQUESTIONS_ANSWER_PREFIX` class-attribute

```
SUBQUESTIONS_ANSWER_PREFIX = 'Subquestions answered:'
```

### `register_for_llm`

```
register_for_llm(agent)
```

Registers the tool for use with a ConversableAgent's language model (LLM).

| PARAMETER | DESCRIPTION                                                   |
| --------- | ------------------------------------------------------------- |
| `agent`   | The agent to which the tool will be registered.<br>**TYPE:**`ConversableAgent` |

### `register_for_execution`

```
register_for_execution(agent)
```

Registers the tool for direct execution by a ConversableAgent.

### `register_tool`

```
register_tool(agent)
```

Register a tool to be both proposed and executed by an agent.
