# Using Plan mode in Data Agent databases

## About Plan mode

Most of the time, when you interact with the Data Agent, you provide prompts to the Data Agent and, after confirming any additional details, the Data Agent immediately performs the requested action.

However, when you ask the Data Agent to perform a very large and complex task, you might want the Data Agent to first create a structured plan to complete the request. This can help to ensure that the Data Agent executes the request correctly and that you don't have to repeat a request.

For example, you might ask the Data Agent to create a database that has a very large schema, or to generate data that includes complex relationships between tables or a long list of specifications for the data values.

After the Data Agent creates the plan, you review it to verify that it will produce the results that you want. To complete your original request, you execute the plan.

To do this type of pre-execution planning, the Data Agent uses Plan mode.

## Changing to Plan mode

### Switching to Plan mode automatically

When you create a database, and provide a schema that contains more than 10 tables, the Data Agent automatically switches to Plan mode. It notifies you when it changes modes.

<figure><img src="https://4109733485-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmoU4gTR9LxlzHeWmQCUZ%2Fuploads%2FOsY5gXDQKOyT5ywgTrEj%2FDataAgent_PlanModeNotification.png?alt=media&#x26;token=955fbf19-d274-424f-ba05-04c87652b55b" alt=""><figcaption><p>Example notification when the Agent automatically switches to Plan mode</p></figcaption></figure>

### Changing to Plan mode manually

You can also change to Plan mode at any time.

The current mode displays at the bottom left of the chat. Agent mode is the default mode, where the Data Agent executes requests immediately. It might request clarification, but it does not create a plan.

To change to Plan mode, click the mode indicator, then select **Plan**.

<figure><img src="https://4109733485-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmoU4gTR9LxlzHeWmQCUZ%2Fuploads%2F9lO5bGi2bHdwN1Mas10G%2FDataAgent_ModeDropdown.png?alt=media&#x26;token=59fe92d6-3cbf-40c3-a848-4e90eaedbb74" alt=""><figcaption><p>Dropdown to change between Plan mode and Agent mode</p></figcaption></figure>

&#x20;You can also prompt the Agent to change to Plan mode. For example:

`Create a plan to add 1000 customers from across Europe to the database. Each customer has between 1-3 orders.`

## How Plan mode works

In Plan mode, the Data Agent takes your request and uses it to create a plan to implement it.

For example, when you create a database with a large, complex schema, it might create a series of phases to generate sets of related tables. For example:

<figure><img src="https://4109733485-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmoU4gTR9LxlzHeWmQCUZ%2Fuploads%2Fk7EOU9mdHFzN1ZL25zze%2FDataAgent_PlanSummary.png?alt=media&#x26;token=05a44017-e3b6-4600-9a2a-44e95d3f691d" alt=""><figcaption><p>Data Agent plan summary</p></figcaption></figure>

The Data Agent writes the plan to a plan document, which it adds to the **Plans** list at the bottom left of the page.

<figure><img src="https://4109733485-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmoU4gTR9LxlzHeWmQCUZ%2Fuploads%2FTOEUNUUJ8PC2xZ2FnsdS%2FDataAgent_PlansList.png?alt=media&#x26;token=69cdaa77-7a02-4dd5-81c3-db37152bc308" alt=""><figcaption><p>Plans list for a Data Agent database</p></figcaption></figure>

## Reviewing the plan

Before you execute the plan, you review the plan details.

<figure><img src="https://4109733485-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmoU4gTR9LxlzHeWmQCUZ%2Fuploads%2F0dkEIBFEIJPjF5crTR6p%2FDataAgent_PlanDetails.png?alt=media&#x26;token=8d3b111d-3c51-4f75-b16e-b5959663cd94" alt=""><figcaption><p>Plan details page</p></figcaption></figure>

The plan details include:

* What the Agent plans to accomplish in each phase of the plan.
* The execution order for the plan phases.
* A progress tracker to track the execution of each phase.

You can use the Agent chat to make adjustments to the plan.

## Executing the plan

When you are satisfied with the plan, to execute it, either:

* On the plan details page, click **Execute plan**.
* In the Agent chat, click **Execute**.

The Data Agent switches to Agent mode, then completes each phase in sequence. It prompts you for any additional information that it needs to complete the phase that it is working on.

The Data Agent shows the execution status below the main chat.

<figure><img src="https://4109733485-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmoU4gTR9LxlzHeWmQCUZ%2Fuploads%2FsbJOWjSNwns18u7fzq78%2FDataAgent_PlanExecutionStatusChat.png?alt=media&#x26;token=4f6b15e4-f307-49e6-8b2d-e9514ea358c4" alt=""><figcaption><p>Execution status for a plan</p></figcaption></figure>

To display the complete list of plan phases, click the plan execution status.

<figure><img src="https://4109733485-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmoU4gTR9LxlzHeWmQCUZ%2Fuploads%2FT8XelZqi7LeNcsy3wzrg%2FDataAgent_PlanExecutionStatusDetails.png?alt=media&#x26;token=148f8a0f-1b6e-42ba-825b-ada8c9daadbe" alt=""><figcaption><p>Plan execution status details</p></figcaption></figure>

From the plan status, to cancel the execution, click **Cancel**.

From the plan status, to display the full plan, click **View Plan**. On the plan details page, the **Progress** section also tracks the execution status.

<figure><img src="https://4109733485-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmoU4gTR9LxlzHeWmQCUZ%2Fuploads%2FaeXPVIrZIPkPxQ1qwkNs%2FDataAgent_PlanDetailsProgress.png?alt=media&#x26;token=409d4703-e7cd-4910-be6a-333e657177a7" alt=""><figcaption><p>Progress section on the plan details page</p></figcaption></figure>

When it finishes, the Data Agent displays a summary of the results and marks the plan as completed.

<figure><img src="https://4109733485-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmoU4gTR9LxlzHeWmQCUZ%2Fuploads%2F7ddFjL50V1zNmggY0DqF%2FDataAgent_PlanCompleted.png?alt=media&#x26;token=6332578a-0655-40df-807a-0fc64870fb77" alt=""><figcaption><p>Completed tag for an executed plan</p></figcaption></figure>

## Deleting a plan

To delete a plan, on the plan details page, click the delete icon.
