# Using the Deviation Agent (QMS)

In Vaults using Veeva AI for Quality, Veeva QMS provides a Deviation Agent that can generate a narrative summary of the investigation or CAPA plan for a _Deviation_. 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 Deviation Agent can also answer questions about a _Deviation_ record via Veeva AI Chat.

## Supported Objects & Object Types

The Deviation Agent supports the following objects and object types:

* _Deviation_: All standard object types
* _Quality Event_: _Deviation_ and _GCP Deviation_ object types

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

Your Vault may process deviations using either a standalone _Deviation_ object or a _Quality Event_ object of the _Deviation_ or _GCP Deviation_ object type. In this article, these objects are collectively referred to as _Deviations_.

## How to Generate a Narrative Summary

To generate a narrative summary:

1. Navigate to a _Deviation_ record with a supported object type.
2. Click **Edit**.
3. Next to the _Investigation Summary & Conclusion_ or _CAPA Plan Summary_ field, click 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 to invoke the Agent for summary generation.
4. Review the generated summary. 
5. Click **Save**.

When you click **Save**, the narrative summary is saved to the field from which you generated it.

If you navigate away from a record while a summary is generating, the summary continues to generate. When summary generation is complete, the **Pending Summary** (<img class="inline" src="https://platform.veevavault.help/assets/images/quality-qms-pending-summary-icon.png" alt="Narrative Summary Generation Icon" style="" />) icon appears next to the relevant field when you navigate back to the record. Clicking on the icon in view mode opens the record in edit mode and populates the pending summary in the applicable field, where you can review and save it. Pending summaries are available for 24 hours after summary generation.

For the best results, we recommend generating a narrative summary only when a record is in its later lifecycle states, and when the data is expected to be most complete.

## Using the Ask Questions Action 

You can ask questions about a _Deviation_ record using Veeva AI Chat. Click the **Veeva AI** (<img class="inline" src="https://platform.veevavault.help/assets/images/Global-AI-Chat-Icon.png" alt="Global AI Chat Icon" style="" />) icon in the upper right of the Vault interface while viewing a record, and begin typing your question into the text box. You can ask questions about the record you are currently viewing, as well as the records related to the primary record.

## Related Permissions

To interact with the Deviation Agent, you 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: Deviation Agent: Execute</td>
   <td>Ability to generate a narrative summary using the Deviation 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>Deviation</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: Deviation: [object type]: Edit</td>
   <td>Ability to edit <em>Deviation</em> records of the relevant object type.</td>
  </tr>
  <tr>
   <td>Security Profile</td>
   <td>Objects: Deviation: Object Field Permissions: CAPA Plan Summary, Investigation Summary & Conclusion: Edit</td>
   <td>Ability to edit relevant fields on <em>Deviation</em> records.</td>
  </tr>
  <tr>
   <td>Atomic Security</td>
   <td>Deviation 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>Deviation Lifecycle</em>. </td>
  </tr>
</table>