**Source URL:** https://qualityone.veevavault.help/en/lr/950647/

# Configuring Agent Tools



**Important**: The functionality described on this page is only available to customers who have Vault AI enabled on their Vault.

Agent tools are a capability that provides your Large Language Model (LLM) additional information from your Vault to help it execute an agent action. When executed, agent tools operate as extensions of agent actions, allowing the action to interact with other areas of your Vault to provide relevant information to Vault AI Chat users.

When assigning an agent tool to an agent action, you may include details on when and how to execute the tool in the agent action's instructions. In addition, you can configure the agent action to always use an assigned agent tool, or let your LLM decide when to employ the agent action. The _Description_ of the agent tool and _Input_ parameters can also help your LLM to understand how to use the agent tool without explicit mention in the instructions.

There are two sets of agent tools: configurable agent tools and built-in agent tools. The following agent tools are configurable when you create an agent tool in **Admin > Configuration > Tools**:

* [VQL Query][6]
* [JSON Response][5] 
* [Agent Action][7]

The following agent tools are built-in, meaning they are ready-made agent tools provided by Veeva. You can assign these agent tools to an agent action, but no further configuration is necessary:

* [Single Item Workflow Task Completion][0]  
* [Ask User][4]

**Note**: Ensure that the _Description_ of the agent tool and _Input_ parameters are clear and concise, as your LLM uses this information to understand the purpose of and how to execute the agent tool. If the _Description_ is easy to understand, your LLM can invoke the agent tool without explicit direction in the agent action instructions.

## VQL Query Agent Tool {#vql-query-agent-tool}

The VQL Query agent tool allows an agent action to query Vault for specific data. For example, VernBio has created a custom _Document Quality Check_ agent action that checks document spelling and grammar. Also, they would like the agent action to check if company terms and acronyms used in documents exist in VernBio's glossary. To accomplish this behavior, they created an agent tool using the _VQL Query Tool Type_, which allows the agent action to query the VernBio _Glossary_ object for accepted terms and phrases. Now, when a user clicks _Document Quality Check_, it will not only provide spelling and grammar checks, but also check if company terms used in the document are available in the glossary.

### How to Configure a VQL Query Agent Tool

To configure a _VQL Query_ agent tool: 
1. Navigate to **Admin** > **Configuration** > **Tools**. 
2. Click **Create**. 
3. Select **VQL Query** as the **Tool Type**. 
4. Enter a **Label**. The API **Name** field value is populated based on the **Label** value. 
5. Set the **Status** to **Active** or **Inactive**. By default, new agent tools are created in the **Active** status. 
6. Enter a **Description**.
7. Under **Input**, click **Add**. This option is not available until you select the _Tool Type_.
8. Enter a **Property**. This value represents the attribute your LLM uses to execute the Agent Tool. For example, if you enter `SELECT id, name__v FROM documents WHERE TONAME(type__v) = 'promotional_piece__c'` in the **Query** field, you would enter `promotional_piece__c` as the _Property_.
9. Select **String**, **Integer**, or **Number** from the **Type** drop-down.
10. Enter a **Description** of the _Input_ parameter.
11. Click **Add**.
12. Enter your VQL statement in the **Query** field.
13. Click **Save**.

The _VQL Query_ agent tool is now created and you can assign it to an agent action.

### Best Practices {#best-practices}

Use the following best practices when configuring agent tools:

* Reference _Input_ parameters in the _Query_ field using the `${parameter_name}` format. Parameter names are case sensitive and must match the _Property_. For example, if you enter `SELECT id, name__v FROM documents WHERE TONAME(type__v) = ${promotional_piece__c}` in the _Query_ field, you must enter `${promotional_piece__c}` as the _Property_.
* Always include an `ORDER BY` clause when using a query that returns multiple records to ensure the LLM receives the most relevant data first within the 1,000 record limit.
* Your LLM uses the agent tool _Description_ to interpret and execute the agent tool within agent actions. Ensure the _Description_ is accurate and easy to understand to help the LLM when executing the agent tool.
* Use the `AS` clause to provide meaningful _Name_ values to fields and help the LLM accurately interpret the data. For example: `status__v AS current_approval_status`.
* Use the developer portal to learn more about VQL syntax.

### Limits {#vql-query-limits}

The following limits apply to configuring agent tools:

* The _VQL Query_ agent tool does not support `LIMIT`, `PAGESIZE`, or `PAGEOFFSET` VQL query clauses.
* The _VQL Query_ agent tool only supports object and document query targets.
* You can add up to ten _Input_ parameters per agent tool.
* _VQL Query_ agent tools can return a maximum of 1,000 records. If the query returns over 1,000 records, only the first 1,000 are sent to the LLM. Subquery limits are determined by your Vault's `MAXROWS` configuration.
* The characters " ' () and \ are escaped if used in _Property_ values. The % and \* characters are not escaped when used in `LIKE` and `FIND` operators.
* The _Property_ field does not support lists and enumerations.
* When using multiple arguments in a `CONTAINS` operator, you must provide multiple individual tokens. For example: `WHERE CONTAINS(${PROD_1}, ${PROD_2})`.
* You must use search phrases in `FIND` VQL clauses as tokens. For example: `FIND( ${search_statement} )` is valid while `FIND( ${prod_1} AND ${prod_2}) `is invalid.

## JSON Response Agent Tool {#json-agent-tool}

The _JSON Response_ agent tool allows you to generate JSON structured data based on input schema. You can execute a custom agent action using a _JSON Response_ agent tool through either Vault Java SDK or Vault API to generate JSON formatted data. External programs, such as Java, can consume the data for processing purposes.

**Important**: When crafting a _Description_ for the _JSON Response_, do not use language that suggests the agent tool _outputs_ a JSON result. This language may cause errors when the agent action invokes the agent tool. Instead, the _Description_ should mention the LLM provides the JSON response. For example, "Generate a JSON output based on the document" may return an error, while "Report the detected language, summary, and keywords for a given document based on its content" is a valid _Description_.

The _JSON Response_ schema supports the following:

* Up to five levels of nesting
* 100 properties per _JSON Response_ agent tool
* Required parameters
* Types:
  * Object
  * Array
  * String
  * Number
  * Integer
  * Date
* Enum data type

The following is an example of the JSON input schema you can use in the _JSON Response_:

~~~ json
{
  "type": "object",
  "properties": {
    "document_id": {
      "type": "string",
      "description": "The document identifier, echoed from input."
    },
    "language": {
      "type": "string",
      "description": "Detected language of the document as an ISO 639-1 two-letter code (example: 'en', 'fr', 'de')."
    },
    "summary": {
      "type": "string",
      "description": "A concise summary of the document content, between two and five sentences."
    },
    "keywords": {
      "type": "string",
      "description": "Up to ten representative keywords extracted from the document and returned as a single comma-separated string (example: 'biology, syllabus, course, grading, schedule')."
    }
  },
  "required": ["document_id", "language", "summary", "keywords"]
}
~~~

### How to Configure a JSON Response Agent Tool

To configure a _JSON Response_ agent tool:

1. Navigate to **Admin** > **Configuration** > **Tools**.
2. Click **Create**.
3. Select **JSON Response** as the **Tool Type**.
4. Enter a **Label**. The API **Name** field value is populated based on the **Label** value.
5. Set the **Status** to **Active** or **Inactive**. By default, new agent tools are created in the **Active** status.
6. Enter a **Description**.
7. Under **Input**, enter the structured JSON input schema in the **JSON Response** field.
8. Click **Save**.

The _JSON Response_ agent tool is now created and you can assign it to an agent action.

## Single Item Workflow Task Completion Agent Tool {#single-item-wf-task-completion}

The _Single Item_ _Workflow Task Completion_ agent tool allows you to create an agent action that can perform and complete document and object record workflow tasks. You can only assign this agent tool to an agent action as it is system-managed. It is recommended to use this agent tool to complete high volume workflow tasks with low complexity, such as those with simple tasks.

To ensure an agent action can complete a workflow task with Single Item Workflow Task Completion, complete the following configurations:

1. Create an object or document agent using an object record or document currently in a workflow. Only single record and single document workflows are supported.

2. Create an agent action for completing a workflow task.
  * Ensure the agent action's _Label_, _Name_, and _Description_ clearly state the purpose is to only complete assigned workflow tasks. For best results, the agent action Label should match as closely as possible to the task Label it is intended to complete. For example, _Work Order Request Workflow: Agent Review Task_ is a valid name for an agent action that completes review tasks in a _Work Order Request_ record workflow.
  * Ensure the agent action's _Instructions_ define how to complete the task, and rules for success and failure. For example, if the workflow prompts for Approved and Rejected verdicts, describe the conditions that can lead to each verdict. Reference prompt for verdict Label values in the Instructions just as they appear in the Vault UI in the agent user's base language. This process is similar to creating a Standard Operating Procedure for a user. See an example [below][1].

3. Assign the **Single Item Workflow Task Completion** agent tool to the agent action.

The agent action is now configured to complete a workflow task. Users can now add the agent user as a participant to the workflow and assign them tasks. It is recommended to first [test your configuration][2] in a sandbox environment. It is also recommended to create one agent action per workflow tasks. It is not recommended for multiple agent actions to complete the same workflow task.

### Referencing Prompts Labels in Instructions {#reference-prompt-labels-in-instructions}

If a task prompts for comments or prompts for verdicts, capacities, or fields, it's important to use the _Label_ values as they appear in the Task step configuration when configuring the agent action _Instructions_. Doing so allows the agent action to pass these required fields to the agent tool for processing. For example, if a _Capacity Value_ is labeled _Agent Approval_, you must use this same label when referencing this field in the _Instructions_. Otherwise, the agent action may fail to accurately interpret the prompt.

See below an example of the agent action _Instructions_. In this example, the _Instructions_ reference the _Approved_ and _Rejected_ verdicts, the _Rejection Comment_, _Approval Comment_, _Approval Capacity_, _Agent Approval_, and _Agent Complexity Assessment_ prompts:

The labels are displayed in the agent action _Instructions_ exactly as they are displayed in the Task step configuration.

### Task Completion 

Once a task is assigned to an agent user, the _Agent Workflow Task Execution_ job sends the task ID and agent user ID to the Super Agent's _Workflow Task Execution_ agent action. Then, _Workflow Task Execution_ routes to and executes the appropriate agent action you created to complete the workflow task. The _Agent Workflow Task Execution_ job runs on an hourly basis by default to locate tasks assigned to agent users in your Vault. Only one task ID is sent to the _Workflow Task Execution_ agent action per task and task iteration.

You must manually run the _Agent Workflow Task Execution_ job when [testing][2] your configuration to avoid the hour wait time.

### Task Priority

Tasks are completed by agent users in order of task due date in ascending order. For example, if the current day is Monday, a task with a due date of Tuesday is processed before a task with a due date of Wednesday. Tasks with null/blank due dates are processed after all other tasks with due dates have been processed.

### Test Your Configuration {#test-agent-configuration}

Follow the steps below to test the agent action and agent tool configuration in a sandbox environment:

1. Configure or use an existing single document or object workflow for testing purposes. Ensure the workflow tasks are not complex (for example, tasks with few verdicts or prompts).
2. Complete the steps [above][0]. Ensure **Support in Chat** is set to **Yes** in the agent action configuration.
3. Add agent context to the agent action that describes the context needed to complete the task.
4. Select the agent action in Vault AI Chat while viewing the document or record that is currently in the workflow. If the agent action _Instructions_ and agent context are valid, the agent action responds with the data that leads to task completion. For example, if the task's verdicts include _Approved_ and _Rejected_, the response includes the task verdict and the conditions that led to the verdict, based on your _Instructions_ configuration.
5. Initiate an agent trace session for the agent user that completes workflow tasks. You can inspect the trace details file for information on errors that may occur during the testing process and the agent action's execution of the task.
6. Start the workflow and ensure the agent user is assigned to the task based on the task participant selection configuration (alternatively, agent users can be assigned to the _Participant_ group downstream in the workflow).
7. Once the agent user is assigned to the task, run the _Agent Workflow Task Execution_ job in the Job Status page.
8. If your configuration is valid, the agent user completes the workflow task. You can view the completion details in the agent trace session logs. Vault sends you an [error notification][3] if the agent user fails to complete the task.

**Note**: _Single Item_ _Workflow Task Completion_ does not support completing eSignature or participant selection tasks. In addition, you can only assign tasks to agent users as making tasks available to agent users is not supported.

### Error Handling {#error-handling}

In the event an agent user fails to complete a task due to an error, an Agent Assignment Error notification is sent to the workflow owner with the reason for the failure. If the workflow was system initiated, the notification is sent to the system provided _Vault Owner_ group. The workflow owner can then cancel the task or reassign it to another user or agent user. If no action is taken, the task remains assigned to the agent user.

If the workflow is reopened, a new iteration of the task is assigned to the agent user. Up to ten task iterations are allowed. If the _Single Item Workflow Task Completion_ agent tool runs into an error, the agent action can retry the agent tool up to three times.

### Limits {#single-item-workflow-completion-limits}

* Only task assignment to agent users is supported and not making tasks available.
* Agent users cannot complete eSignature tasks.
* Agent users cannot assign users to _Partcipant_ groups.
* Object reference fields values are supported with _Prompt for Fields_ if _Values must be unique_ is enabled on the _Name_ (`name__v`) field on the referenced object record is unique. This ensures that when the agent passes the _Label_ value to the LLM that the referenced object record value is uniquely identified.
* Only single document and single object record workflows are supported.

## Ask User {#ask-user}

The _Ask User_ tool type allows Vault AI Chat to pause an agent action's execution and ask clarifying questions before moving forward. _Ask User_ can prompt the user to answer the clarifying question through text input or single or multiple choice selection.

You can only assign this agent tool to an agent action as it is system-managed. You cannot perform any configurations. By default, _Ask User_ is assigned to the _Ask Questions_, _Translate Page_, and _Translate Record_ agent actions. See Using Vault AI Chat for more details on how _Ask User_ operates with these agent actions.

It is recommended to assign _Ask User_ to an agent action that requires additional user input before the action can execute. For example, a _Spell Check_ agent action could use _Ask User_ to prompt the user to provide the specific page or pages to check. The agent action _Instructions_ must define how to use the _Ask User_ agent tool.

Navigate to **Admin > Configuration > Tools > Ask User > Configuration** for more details on how and when to use _Ask User_.

**Note**: _Ask User_ is executed only if _Support Chat_ is enabled on the agent action.

### Answer Formats

_Ask User_ can respond to users in the following formats:

* **Text Input Questions**: Use this format to allow the user to provide their answer in a text input field. This format is valuable for open-ended responses that allow the user to explain information in their own words. For example, if _Ask Questions_ is executed on a document, Vault AI Chat asks the user to provide what they would like to know about the document.
* **Single Selection**: Use this format to require the user to select one answer from a list of choices. This format is ideal for **Yes**/**No** and **Continue**/**Cancel** questions to ask the user. For example, the _Translate Record_ agent action asks users to select a language to translate the record to from a list of languages.
* **Multiple Selection**: Use this format when you need the user to select multiple answers from a list of choices. For example, a user may ask "What's the approval rate for _Work Order Request_ workflows". In this scenario, _Ask User_ could respond with multiple choice answers asking "Please choose one or more timeframes for approval rates: Q1, Q2, Q3, Q4".

**Note**: You can use an alternative option for _Single Selection_ and _Multiple Selection_ formats if none of the provided choices are applicable to the user. For example, _Translate Page_ allows users to enter their own translation language rather than select from a list of provided languages. Ensure the parameters around using the alternative option are defined in the agent action's _Instructions_.

## Agent Action {#agent-action}

The _Agent Action_ tool type allows an agent to execute another agent's agent action as a sub-agent action. For example, consider a _Summarize Course_ object agent action that summarizes a course based on a _Course_ record and its related records and documents, such as _Syllabus_ and _Course Brochure_. You can create an _Agent Action_ tool type with _Summarize Course_ assigned to it. Then, you can assign this _Agent Action_ tool type to the Super Agent's _Chat Action_. Once assigned, a user can ask the _AI_ tab which Biology courses are available, which prompts the _Query Agent_ to process the question. Then, the user could ask for a summary of a specific Biology course, which executes the _Agent Action_ tool type which then executes the _Summarize Course_ agent action through the agent tool call.

In addition, you can assign [_Ask User_][4] to an agent action defined in the _Agent Action_ tool type. When an agent action is executed via the tool type, it can request additional input from the end user.

### How to Configure an Agent Action Tool Type

To configure an _Agent Action_ tool type:

1. Navigate to **Admin** > **Configuration** > **Tools**.  
2. Click **Create**.  
3. Select **Agent Action** as the **Tool Type**.  
4. Enter a **Label**. The API **Name** field value is populated based on the **Label** value.  
5. Set the **Status** to **Active** or **Inactive**. By default, new agent tools are created in the **Active** status.  
6. Enter a **Description**. Ensure that the _Description_ is clear and easy to understand, as your LLM uses this information to understand the purpose of and how to execute the agent tool. At runtime, Vault includes this _Description_, the agent action's _Description_, and the agent's _Objective_. You can observe these values in the JSON agent trace details file  when  the _Agent Action_ tool type is executed.  
7. Select an **Agent**. You can only select an active custom agent.  
8. Select an **Agent Action** associated with the agent. You can only select an active custom agent action.  
9. Optional: Enter a **User Message Description**. If the _Agent Action_ tool type is triggered by user input in Vault AI Chat, this message tells the agent what information to pass to the agent action from the user. You can use this message to ensure certain user questions or requests are routed appropriately to this agent action.  
10. Optional: Enter a **Document ID Description** if you selected a document agent or a **Record ID Description** if you selected an object agent. This field helps the agent action choose the correct record or document when it is executed.   
11. Click **Save**.

The _Agent Action_ tool type is now created and you can assign it to one or more agent actions.

**Note**: You cannot delete an agent action currently in use by the _Agent Action_ tool type.

[0]: #single-item-wf-task-completion
[1]: #reference-prompt-labels-in-instructions
[2]: #test-agent-configuration
[3]: #error-handling
[4]: #ask-user
[5]: #json-agent-tool
[6]: #vql-query-agent-tool
[7]: #agent-action
