# Configuring the Complaint Agent (QMS)

In Vaults using Veeva AI for Quality, Veeva QMS provides a Complaint Agent that can generate a narrative summary of the investigation or CAPA plan for a _Complaint_. The summary includes information from key related records, such as _Investigations_ and _Root Causes_ for an investigation summary, and _CAPA Actions_ for a CAPA plan summary. The Complaint Agent can also answer questions about a _Complaint_ record via Veeva AI Chat.

See below for definitions of terms used in this article:

* **Agent:** Defines a set of Agent Actions that can be performed on a document or object record in your Vault.
* **Agent Objective**: A description of the Agent's roles and responsibilities, similar to a job description.
* **Agent Context:** Defines the information an Agent knows about your Vault, allowing the Agent Action to summarize this information in a response. Agent Context can include data from an object record such as fields and object relationships.
* **Agent Actions:** The actions that the Agent can perform. Agents perform Agent Actions based on the provided Objective, Context, and instructions.
* **Agent Tools:** Tools are assigned to Agent Actions, and provide the structure for the Agent's response in order to ensure a consistent output format. Agent Tools are not editable.

## Supported Objects & Object Types {#objects}

The Complaint Agent supports the following objects and object types:

* _Complaint_: _Pharma Complaint_ and _Medtech Complaint_ object types. Generating a CAPA summary for records of the _Medtech Complaint_ object type is not supported.
* _Quality Event_: _Complaint_ and _Medtech Complaint_ object types. Generating a CAPA summary for records of the _Medtech Complaint_ object type is not supported.

The Complaint Agent does not support custom objects and object types.

Your Vault may process complaints using either a standalone _Complaint_ object or a _Quality Event_ object of a _Complaint_ or _Medtech Complaint_ object type. In this article, these objects are collectively referred to as _Complaints_. All configuration steps in this article also apply to the supported object types of the _Quality Event_ object.

## Supported Agent Actions

The following Agent Actions are available for the Complaint Agent on supported objects and object types:

* **Ask Questions about the Complaint**: Lets users ask the Complaint Agent questions about a _Complaint_ record via the Veeva AI Chat interface.
* **Generate Investigation Summary**: Lets users summarize an investigation by clicking the **Generate Summary** (<img class="inline" src="https://platform.veevavault.help/assets/images/quality-qms-nsg-icon.png" alt="Narrative Summary Generation Icon" style="" />) icon next to the _Investigation Summary & Conclusion_ field on a _Complaint_ record.
* **Generate CAPA Summary**: Lets users summarize a CAPA plan by clicking the **Generate Summary** (<img class="inline" src="https://platform.veevavault.help/assets/images/quality-qms-nsg-icon.png" alt="Narrative Summary Generation Icon" style="" />) icon next to the _CAPA Plan Summary_ field on a _Complaint_ record. This action is not supported for the _Medtech Complaint_ object type.

## Configuration Overview

To configure the Complaint Agent, complete the following steps:

* [Activate][1] the Complaint Agent
* [Configure][2] summary fields on the _Complaint_ object
* Optional: [Configure][3] Agent Actions
* Optional: [Configure][4] custom Agent Context
* [Configure][5] user permissions

## Activating Agents {#activate}

You must activate the Agents in order to make them available for use. To activate, navigate to **Admin > Configuration > Agents > Complaint Agent**, and set the _Status_ of the Agent to _Active_.

## Configuring Object Fields {#fields}

Activate the following Rich Text fields on the _Complaint_ object and add them to the [relevant object types][6] and layouts:

* _CAPA Plan Summary_ (`capa_plan_summary_rt__v`)
* _Investigation Summary & Conclusion_ (`investigation_summary_conclusion_rt__v`)

We recommend hiding these fields via [Atomic Security](/en/lr/47850/) or [layout rules](/en/lr/51632/) in earlier lifecycle states and exposing them only during the later stages of the lifecycle, when your data is expected to be most complete for summary generation.

<div class="note-border alert-info">
  <div class="alert alert-info" role="alert">
    <div><i class="far fa-info-circle"></i></div>
    <div class="alert-text">
      <p><strong>Note</strong>: The Rich Text fields listed above are distinct from the similarly labelled <em>CAPA Plan Summary</em> (<code class="language-plaintext highlighter-rouge">capa_plan_summary__v</code>) and <em>Investigation Summary &amp; Conclusion</em> (<code class="language-plaintext highlighter-rouge">investigation_summary_conclusion__v</code>) Text fields on the <em>Complaint</em> object. These fields are not supported for narrative summary generation.</p>
    </div>
  </div>
</div>



## Configuring Actions {#actions}

You can configure standard Agent Actions by adding custom context and corresponding _Supplemental Instructions_ to let that action know that custom context exists for the action. See [Configuring Context][4] for more information about creating custom context.

You can also optionally configure new custom Agent Actions in order to extend the capabilities of the Complaint Agent to address your business needs.

## Configuring Context {#context}

You can optionally configure custom Agent Context in order to define additional related records and fields for the Agents to summarize. If using custom context, we recommend including similar objects, fields, and relationships as the standard context for optimal results.

1. Navigate to **Admin > Configuration > Agents > Complaint Agent**.
2. Expand the **Context** section and click **Create**.
3. From the **Type** drop-down, select **Object Data**.
4. Enter a **Label**.
5. Enter a **Name**.
6. Optional: Enter a **Description**.
7. Select an option for **Always Include**. This determines if the Agent always summarizes the information specified in this context.
8. In the _Configuration_ section, click **Generate Default** to populate the _Object Fields_ box with the default context for the Agent. You can modify the related objects and fields referenced in the generated context to suit your business needs. You can also write your own context using the same syntax as in [Word formatted output templates](/en/lr/796234/).
9. Click **Save**.
10. Navigate back to the Agent and select an **Action** from the _Actions_ section.
11. In the _Available Context_ section, click **Add**.
12. In the dialog, select the context you created.
13. Click **OK**.
14. On the Action, click **Edit**.
15. Optional: Add **Supplemental Instructions** to let the Agent know that custom context exists for this Action.
16. Click **Save**.

If you wish to only use a custom context for any of the available Agent Actions, you can inactivate the standard context by navigating to the context and setting the _Status_ to _Inactive_.

### Data Model Migration Considerations for Custom Context

When migrating to a standalone [quality event data model](/en/lr/722050/), any custom context configured for the Complaint Agent must be deleted and recreated after migration is complete. Vault automatically updates the object and field references for standard context. If you are not using custom context, no action is required to reconfigure the Agents after transitioning to a standalone data model.

## Limitations

The following limitations affect the Complaint Agent:

* Summarize up to 10 related records per object relationship. For instance, the summary of an _Investigation_ can include up to 10 related _Root Cause_ records.
* A summary cannot be generated in a custom target field. You must use the standard _Investigation Summary & Conclusion_ and _CAPA Plan Summary_ fields.
* Generated summaries can contain up to 5,000 characters.
* Agents cannot summarize field values on the _Complaint_ record that have been edited without saving the record. Edits to related records made while editing the primary _Complaint_ are included in the summary.

## User Permissions {#user-permissions}

To interact with the Complaint Agent, users must have the following permissions:

<table>
  <tr>
   <th>Type</th>
   <th>Permission Label</th>
   <th>Controls</th>
  </tr>
  <tr>
   <td>Security Profile</td>
   <td>Agents: Complaint Agent: Execute</td>
   <td>Ability to generate a narrative summary using the Complaint Agent.</td>
  </tr>
  <tr>
   <td>Security Profile</td>
   <td>Agents: Super Agent: Execute</td>
   <td>Ability to ask questions via Veeva AI Chat about a <em>Complaint</em> record.</td>
  </tr>
  <tr>
   <td>Security Profile</td>
   <td>Application: Vault Actions: Veeva AI Chat: Use Chat</td>
   <td>Ability to view and interact with Veeva AI Chat.</td>
  </tr>
  <tr>
   <td>Security Profile</td>
   <td>Objects: Complaint: Pharma Complaint, Medtech Complaint: Edit</td>
   <td>Ability to edit <em>Pharma Complaint</em> and <em>Medtech Complaint</em> records.</td>
  </tr>
  <tr>
   <td>Security Profile</td>
   <td>Objects: Complaint: Object Field Permissions: CAPA Plan Summary, Investigation Summary & Conclusion: Edit</td>
   <td>Ability to edit relevant fields on <em>Complaint</em> records.</td>
  </tr>
  <tr>
   <td>Atomic Security</td>
   <td>Complaint Lifecycle: [state]: Atomic Security: Fields: CAPA Plan Summary, Investigation Summary & Conclusion: Edit</td>
   <td>Ability to edit relevant fields in applicable lifecycle states of the <em>Complaint Lifecycle</em>. </td>
  </tr>
</table>

## Related Permissions

The following permissions control your ability to configure Agents:

<table>
  <tr>
   <th>Type</th>
   <th>Permission</th>
   <th>Access Details</th>
  </tr>
  <tr>
   <td>Security Profile</td>
   <td>Admin: Agents: Edit</td>
   <td>Ability to edit and configure Agents.</td>
  </tr>
  <tr>
   <td>Security Profile</td>
   <td>Admin: Tools: Edit</td>
   <td>Ability to edit Agent Tools.</td>
  </tr>
  <tr>
   <td>Security Profile</td>
   <td>Agent Instance: Read</td>
   <td>Ability to view the <em>Agent Instance</em> object.</td>
  </tr>
  <tr>
   <td>Security Profile</td>
   <td>Agent Action Execution: Read</td>
   <td>Ability to view the <em>Agent Action Execution</em> object.</td>
  </tr>
  <tr>
   <td>Security Profile</td>
   <td>Admin: Objects: Edit</td>
   <td>Ability to edit and configure Vault objects.</td>
  </tr>
  <tr>
   <td>Security Profile</td>
   <td>Admin: Permission Sets: Edit</td>
   <td>Ability to edit and configure permission sets.</td>
  </tr>
</table>

[1]: #activate
[2]: #fields
[3]: #actions
[4]: #context
[5]: #user-permissions
[6]: #objects