> For the complete documentation index, see [llms.txt](https://docs.uptiq.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uptiq.ai/academy/tier-2-core-skills/m07-governance-rbac-ai-gateway-configuration/lab-7-configure-and-validate-policy-based-guardrails.md). Agents can also search and read this documentation through its [MCP server](https://docs.uptiq.ai/~gitbook/mcp).

# Lab 7: Configure and validate policy-based guardrails

Hands-on lab for lesson 7 of module M07, configure and validate policy-based guardrails.

{% @uptiq-training/training-labels content="Module 7 | brand
Lesson 7 of 8 | brand
Lab 7 | success
13 minutes | neutral
Bloom level Apply | neutral" %}

{% @uptiq-training/training-navigator title="M07 Governance, RBAC & AI Gateway Configuration" content="Lesson 1: Understand the Platform's governance architecture and Control Center | soon
Lesson 2: Configure RBAC roles and enforce separation of duties | soon
Lab 2: Configure RBAC roles and enforce separation of duties
Lesson 3: Set up Microsoft SSO and Entra ID integration | soon
Lab 3: Set up Microsoft SSO and Entra ID integration
Lesson 4: Knowledge check 1 | soon
Lesson 5: Configure the AI Gateway for production model families | soon
Lab 5: Configure the AI Gateway for production model families
Lesson 6: Configure agent authentication and widget identity tokens | soon
Lab 6: Configure agent authentication and widget identity tokens
Lesson 7: Configure and validate policy-based guardrails | soon
Lab 7: Configure and validate policy-based guardrails | current
Lesson 8: Module assessment | soon" %}

## Lab overview

**Exercise title:** Configure and Validate Policy-Based Guardrails

**Difficulty level:** Apply (Bloom Level 3 — you will configure a real system and observe the results, not just recall or recognize concepts)

**Estimated hands-on time:** 13 minutes (of a 17-minute lesson; the first 4 minutes are a screencasted demo you watch before starting)

**What you will build:** You will configure two agent-level guardrails on the borrower onboarding agent from M03 — Sensitive Data Masking (PII masking for SSN) and Tool Execution Approval (for the credit bureau query action) — and then validate that both guardrails are working by inspecting the Run & Trace log.

**Prerequisites:**

* The borrower onboarding agent from M03 must exist in your sandbox. If it does not appear in Agent Builder, contact your sandbox administrator before proceeding.
* The credit bureau query action must be attached to that agent as a skill. Confirm this in the agent's Skills section before starting Procedure 2.
* Your sandbox account must have Developer, Account Admin, or Org Admin access. Viewer-only access cannot configure guardrails.
* The agent must be on a compatible executor version for PII tokenization. Confirm this in `Agent Config → Runtime & Versioning` before enabling Sensitive Data Masking. If you are unsure which version is required, check with your sandbox administrator.

{% hint style="warning" %}
Complete the executor version check before enabling Sensitive Data Masking. If the agent is on an incompatible executor version, PII tokenization will not function and the SSN will not be masked in the Run & Trace log.
{% endhint %}

## Your sandbox environment

**Environment access URL:** `<provided by your instructor>`

| **Connection detail**         | **Where to find it**                                                                         |
| ----------------------------- | -------------------------------------------------------------------------------------------- |
| **Sandbox login credentials** | Provided in your course welcome email                                                        |
| **Borrower onboarding agent** | Agent Builder → your agent list → "Borrower Onboarding" (from M03)                           |
| **Credit bureau query skill** | Agent Builder → your agent → Skills panel — confirm it appears before starting Procedure 2   |
| **Run & Trace log**           | Agent Builder → your agent → monitoring section, OR Control Center → Observe → Runs & Traces |

**Pre-provisioned resources — you do not need to set these up:**

* The borrower onboarding agent itself (built in M03)
* The credit bureau query action, already attached to the agent as a skill
* Your sandbox user account and role assignment
* The AI Gateway model configuration (set up in M07 Phase 3)

{% hint style="info" %}
The Run & Trace log is accessible from two places: inside Agent Builder under your agent's monitoring section, and from Control Center → Observe → Runs & Traces. Either path shows the same data. If you cannot find it in one location, try the other.
{% endhint %}

## Configuration template

This template summarizes the configuration values you will enter during the lab. Refer back to it during Procedures 1 and 2.

### Sensitive Data Masking (Procedure 1)

| **Field**              | **Value**                       | **Notes**                                                                         |
| ---------------------- | ------------------------------- | --------------------------------------------------------------------------------- |
| **Guardrail toggle**   | Sensitive Data Masking — **On** | Toggle in `Agent Config → Guardrails`                                             |
| **Masking provider**   | **Regex**                       | Do not select Google Cloud DLP for this exercise — SSN is available through Regex |
| **List type**          | **Deny list**                   | Mask only the selected entity types                                               |
| **Entity type to add** | **SSN**                         | Social Security number — available in the Regex provider's entity type list       |

### Tool Execution Approval (Procedure 2)

| **Field**                          | **Value**                                                                                          | **Notes**                                             |
| ---------------------------------- | -------------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
| **Guardrail toggle**               | Tool Execution Approval — **On**                                                                   | Toggle in `Agent Config → Guardrails`                 |
| **Scope**                          | **Per-skill** (preferred) or **All skills** (fallback if per-skill is unavailable in your sandbox) | See Step 2.3 for the decision rule                    |
| **Skill to gate**                  | **Credit bureau query**                                                                            | Locate this skill in the approval configuration panel |
| **Approval toggle for that skill** | **On**                                                                                             |                                                       |

{% hint style="warning" %}
After toggling either guardrail on, you must select the gear icon in that row to open the configuration panel. Toggling the guardrail on without opening the gear icon leaves the guardrail enabled but unconfigured — no entity types are selected for masking, and no skills are gated for approval. The toggle and the gear icon are two separate actions.
{% endhint %}

## Step-by-step instructions

### Procedure 1 — Configure PII Masking for SSN

{% stepper %}
{% step %}
**Open the borrower onboarding agent in Agent Builder**

Open Agent Builder and locate the borrower onboarding agent you built in M03. Select it to open it.

You should see the agent's canvas with its instructions, skills, and configuration tabs visible.

{% hint style="info" %}
**Checkpoint:** Confirm the agent name matches the one you built in M03. If you see a different agent, navigate back to the agent list and select the correct one.
{% endhint %}

> *Agent Builder canvas open with the borrower onboarding agent loaded, showing the agent name in the toolbar and the Skills panel visible*
> {% endstep %}

{% step %}
**Navigate to Agent Config → Guardrails**

In the agent's left navigation or top configuration tabs, select Agent Config, then select Guardrails.

You should see the Guardrails page listing the three guardrail types: Sensitive Data Masking, Tool Execution Approval, and the Model Policy guardrails (which are always enforced and cannot be toggled).

> *Agent Config → Guardrails page showing the guardrails list with Sensitive Data Masking, Tool Execution Approval, and Model Policy rows visible*

{% hint style="info" %}
**Concept:** The Model Policy guardrails (Allowed LLM Families and Providers) are always enforced by the AI Gateway at the organization level. They appear on this page for visibility, but you cannot toggle them off per agent — they are set by your organization's AI Gateway configuration, which you worked with in Phase 3 of this module.
{% endhint %}
{% endstep %}

{% step %}
**Enable Sensitive Data Masking**

Select the toggle next to Sensitive Data Masking to turn it on.

The toggle should move to the enabled (on) position. The row will update to show the guardrail is active.

{% hint style="warning" %}
Do not navigate away yet. Turning the toggle on is not enough — you must open the gear icon in the next step to configure which entity types are masked. An enabled but unconfigured guardrail does not mask anything.
{% endhint %}
{% endstep %}

{% step %}
**Open the masking configuration panel**

Select the gear icon in the Sensitive Data Masking row.

The configuration panel should open, showing options for masking provider, list type (deny list or allow list), and entity type selection.
{% endstep %}

{% step %}
**Select the Regex masking provider**

In the masking provider dropdown, select Regex.

The entity type list should update to show the six entity types available through the Regex provider, including SSN.

{% hint style="info" %}
**Tip:** The Regex provider detects 6 entity types. The Google Cloud DLP provider detects 133. For this exercise, use Regex — SSN is one of its six types, and Regex is the correct choice when you need to mask a specific, well-defined identifier like a Social Security number without enabling broad PII detection across 133 categories.
{% endhint %}
{% endstep %}

{% step %}
**Configure the deny list to include SSN**

Confirm that Deny list is selected as the list type (mask only the selected entity types).

In the entity type list, locate and select SSN (Social Security number).

The SSN entity type should appear as selected or checked in the deny list.

{% hint style="info" %}
**Checkpoint:** Confirm that (a) the masking provider is set to Regex, (b) the list type is Deny list, and (c) SSN is selected. If any of these three are wrong, the masking test in Procedure 3 will not produce a masked token.
{% endhint %}
{% endstep %}

{% step %}
**Save the PII masking configuration**

Select Save to save the Sensitive Data Masking configuration.

You should be returned to the Guardrails page, with Sensitive Data Masking showing as enabled and configured.
{% endstep %}
{% endstepper %}

### Procedure 2 — Configure Tool Execution Approval for the Credit Bureau Query

{% stepper %}
{% step %}
**Return to the Guardrails page**

If you are not already on `Agent Config → Guardrails`, navigate back to it now.

You should see the Guardrails page with Sensitive Data Masking now showing as enabled.
{% endstep %}

{% step %}
**Enable Tool Execution Approval**

Select the toggle next to Tool Execution Approval to turn it on.

The toggle should move to the enabled position.

{% hint style="warning" %}
As with PII masking, turning the toggle on is not enough. You must open the gear icon to configure which skills require approval. Do not navigate away before completing Step 2.3.
{% endhint %}
{% endstep %}

{% step %}
**Open the tool approval configuration panel**

Select the gear icon in the Tool Execution Approval row.

The configuration panel should open, showing the option to enable approval for all skills or to configure approval per skill. You should also see a list of the skills currently attached to the agent.

> *Tool Execution Approval configuration panel open, showing the per-skill approval toggle list with the credit bureau query skill visible*

{% hint style="info" %}
**Concept:** Enable for all skills covers every current and future skill attached to the agent — if you add a new skill later, it is automatically gated. Per-skill approval lets you gate only specific high-risk actions, leaving lower-risk skills to run without interruption. For a credit bureau query — which pulls sensitive financial data on a borrower — per-skill approval is the appropriate choice in a production environment.
{% endhint %}
{% endstep %}

{% step %}
**Enable approval for the credit bureau query skill**

Locate the credit bureau query skill in the list.

If per-skill configuration is available in your sandbox, enable the approval toggle for the credit bureau query skill only. If per-skill configuration is not available in your sandbox, select Enable for all skills instead.

The credit bureau query skill's approval toggle should show as enabled (or the all-skills toggle should be on).

{% hint style="info" %}
**Checkpoint:** Confirm the credit bureau query skill appears in the list. If it does not appear, the skill is not attached to the agent. Stop here and re-attach the credit bureau query action as a skill before continuing — the tool approval guardrail only covers skills that are attached.
{% endhint %}
{% endstep %}

{% step %}
**Save the tool approval configuration**

Select Save to save the Tool Execution Approval configuration.

You should be returned to the Guardrails page, with both Sensitive Data Masking and Tool Execution Approval showing as enabled.
{% endstep %}
{% endstepper %}

### Procedure 3 — Validate PII Masking in the Run & Trace Log

{% stepper %}
{% step %}
**Run a test query containing an SSN**

Navigate to the agent's chat or Try Agent panel. Submit the following test message:

> My SSN is 123-45-6789, can you help me with my loan application?

The agent should respond to your query. The response itself may or may not reference the SSN — what matters is what the Run & Trace log records, not what the agent says back to you.
{% endstep %}

{% step %}
**Open the Run & Trace log**

Open the Run & Trace log for this agent. You can access it from:

* Inside Agent Builder: your agent's monitoring section, or
* `Control Center → Observe → Runs & Traces`

Locate the run you just triggered (it will be the most recent entry).

> *Runs & Traces list showing the most recent run entry for the borrower onboarding agent*
> {% endstep %}

{% step %}
**Confirm the SSN is replaced with an opaque token**

Open the run's trace detail. In the trace, locate the content that was sent to the model.

Confirm that the value `123-45-6789` does not appear anywhere in the trace. In its place, you should see an opaque token — a system-generated reference string that stands in for the original SSN value. The original SSN is stored in the vault; the model never sees it.

> *Run & Trace detail view showing the input content with an opaque token in place of the SSN value*

{% hint style="info" %}
**Checkpoint:** If you can see `123-45-6789` in the trace, PII masking is not working. Check: (a) Is the Sensitive Data Masking toggle on? (b) Did you open the gear icon and save the configuration? (c) Is the masking provider set to Regex with SSN on the deny list? (d) Is the agent on a compatible executor version? See the Troubleshooting Quick Reference for the full diagnostic path.
{% endhint %}

{% hint style="info" %}
**Concept:** The original SSN value is stored in the vault — a secure store that maps each original PII value to its opaque token. An authorized downstream step (such as a document generation tool that needs to print the SSN on a form) can restore the original value from the vault. The model itself never receives the raw SSN, which means it cannot inadvertently include it in a response or log it in a way that creates a compliance exposure.
{% endhint %}
{% endstep %}
{% endstepper %}

### Procedure 4 — Validate Tool Execution Approval in the Run & Trace Log

{% stepper %}
{% step %}
**Run a query that invokes the credit bureau query action**

In the agent's chat or Try Agent panel, submit a query that would cause the agent to call the credit bureau query skill. For example:

> Please pull the credit report for this borrower and summarize their credit score and open accounts.

The agent should pause before executing the credit bureau query and present an Allow / Deny prompt in the conversation.

> *Agent conversation showing the Tool Execution Approval prompt with Allow and Deny buttons visible*

{% hint style="info" %}
**Checkpoint:** If the agent does not pause and instead runs the credit bureau query without prompting you, the Tool Execution Approval guardrail is not active for that skill. Check: (a) Is the Tool Execution Approval toggle on? (b) Did you open the gear icon and save the configuration? (c) Is the credit bureau query skill listed and toggled on in the approval configuration? See the Troubleshooting Quick Reference.
{% endhint %}
{% endstep %}

{% step %}
**Select Allow or Deny and observe the agent's response**

Select Allow or Deny in the approval prompt.

* If you select **Allow**: the credit bureau query runs and the agent continues with the result.
* If you select **Deny**: the credit bureau query is skipped. The agent continues the run without the tool's output — it does not stop entirely.

Observe the agent's response to confirm it behaves as expected for your choice.

{% hint style="info" %}
**Tip:** Try this step twice — once selecting Allow and once selecting Deny — to see both outcomes. A denied call is skipped and the run continues; the agent is not stopped or errored out.
{% endhint %}
{% endstep %}

{% step %}
**Confirm the tool approval event appears in the Run & Trace log**

Open the Run & Trace log and locate the run you just triggered. Open its trace detail.

Confirm that the tool approval event appears as a recorded action in the trace — you should see the credit bureau query call, the approval prompt, and your Allow or Deny response recorded in the execution trace.

> *Run & Trace detail view showing the tool approval event recorded in the execution trace, with the Allow or Deny outcome visible*

{% hint style="info" %}
**Checkpoint:** The tool approval event must appear in the trace as a recorded action. This is the "reason on record" that the governance layer requires — a denied tool call is not silently skipped; it is logged in the execution trace with the outcome. If the event does not appear in the trace, confirm you are looking at the correct run (the most recent one) and that you opened the trace detail rather than the run summary.
{% endhint %}

{% hint style="success" %}
**Best practice:** In a production environment, review the Run & Trace log periodically to confirm that tool approval events are being recorded as expected. The trace is your audit trail — it shows which tool calls were approved, which were denied, and by whom, for every agent run.
{% endhint %}
{% endstep %}
{% endstepper %}

## Troubleshooting

<details>

<summary>Fixes for common problems in this lab</summary>

| **Symptom**                                                                                    | **Cause**                                            | **Fix**                                                                                                                                                                                                                         |
| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **SSN value (`123-45-6789`) is visible in the Run & Trace log — not replaced with a token**    | PII masking is not configured correctly              | Confirm: (1) Sensitive Data Masking toggle is **On**; (2) gear icon was opened and configuration was saved; (3) masking provider is **Regex**; (4) **SSN** is on the deny list. All four must be true.                          |
| **Sensitive Data Masking toggle is on but the gear icon opens an empty or unconfigured panel** | Guardrail was toggled on but never configured        | Open the gear icon, select **Regex** as the provider, add **SSN** to the deny list, and save.                                                                                                                                   |
| **PII masking is configured correctly but the SSN is still not masked**                        | Agent is on an incompatible executor version         | Go to `Agent Config → Runtime & Versioning` and confirm the executor version supports PII tokenization. If it does not, update the executor version and re-run the test.                                                        |
| **Agent does not pause for tool approval — credit bureau query runs without prompting**        | Tool Execution Approval is not active for that skill | Confirm: (1) Tool Execution Approval toggle is **On**; (2) gear icon was opened and configuration was saved; (3) the credit bureau query skill is listed and its approval toggle is **On** (or all-skills approval is enabled). |
| **Credit bureau query skill does not appear in the tool approval configuration panel**         | Skill is not attached to the agent                   | Return to the agent canvas and attach the credit bureau query action as a skill. Then return to `Agent Config → Guardrails` and configure approval for it.                                                                      |
| **Wrong masking provider selected (Google Cloud DLP instead of Regex)**                        | Provider mismatch                                    | Open the gear icon for Sensitive Data Masking, change the provider to **Regex**, re-add **SSN** to the deny list, and save. Google Cloud DLP also supports SSN detection, but this exercise specifies Regex.                    |
| **Cannot find the Run & Trace log**                                                            | Navigating to the wrong location                     | The log is accessible from two places: (1) inside Agent Builder under your agent's monitoring section, or (2) `Control Center → Observe → Runs & Traces`. Try both.                                                             |
| **Guardrail configuration changes are not saving**                                             | Navigating away before saving                        | Always select **Save** before leaving the configuration panel. There is no auto-save.                                                                                                                                           |

</details>

## Checkpoints and validation

### Embedded Checkpoints (Formative)

These checkpoints appear throughout the procedures above. Collect them here for a quick end-of-lab review.

#### Checkpoint 1 — Executor version (before starting)

Confirm the borrower onboarding agent is on a compatible executor version for PII tokenization (`Agent Config → Runtime & Versioning`). If it is not, resolve this before enabling Sensitive Data Masking.

#### Checkpoint 2 — PII masking configuration (after Step 1.6)

Confirm all three of the following are true before saving:

* Masking provider: **Regex**
* List type: **Deny list**
* Entity type selected: **SSN**

#### Checkpoint 3 — Credit bureau query skill attached (before Step 2.4)

Confirm the credit bureau query skill appears in the tool approval configuration panel. If it does not, the skill is not attached to the agent — re-attach it before continuing.

#### Checkpoint 4 — SSN masked in the trace (after Step 3.3)

Confirm that `123-45-6789` does not appear anywhere in the Run & Trace log for the test query. An opaque token should appear in its place.

#### Checkpoint 5 — Tool approval prompt appears (after Step 4.1)

Confirm the agent pauses and presents an Allow / Deny prompt before executing the credit bureau query.

#### Checkpoint 6 — Tool approval event recorded in the trace (after Step 4.3)

Confirm the tool approval event — including your Allow or Deny response — appears as a recorded action in the Run & Trace log for that run.

The lesson outline specifies no summative assessment for this lesson. The live validation steps in Procedures 3 and 4 serve as the performance check for EO-7.5. The summative assessment covering EO-7.5 is in Lesson 8.

## Solution reference

This section shows the complete, correct final state of the agent's guardrail configuration after all four procedures are successfully completed.

### Final Guardrail Configuration — Agent Config → Guardrails

| **Guardrail**                                         | **Status**      | **Configuration**                                                                            |
| ----------------------------------------------------- | --------------- | -------------------------------------------------------------------------------------------- |
| **Sensitive Data Masking**                            | **On**          | Provider: Regex · List type: Deny list · Entity types: SSN                                   |
| **Tool Execution Approval**                           | **On**          | Scope: Per-skill (or All skills if per-skill unavailable) · Gated skill: Credit bureau query |
| **Model Policy (Allowed LLM Families and Providers)** | Always enforced | Set at organization level in AI Gateway — not configurable per agent                         |

### Final State — Run & Trace Log After Validation

#### PII masking test run

* Input query submitted: `My SSN is 123-45-6789, can you help me with my loan application?`
* Expected trace content: The value `123-45-6789` does not appear. An opaque token (system-generated reference string) appears in its place in the content sent to the model.
* The original SSN value is stored in the vault and is not visible in the trace.

#### Tool approval test run

* Input query submitted: a query that invokes the credit bureau query action
* Expected conversation behavior: the agent pauses and presents an Allow / Deny prompt before executing the skill
* Expected trace content: the tool approval event is recorded as a logged action, including the outcome (Allow or Deny) and the skill that was gated

### What the Completed Lab Environment Looks Like

When all four procedures are complete and both validation tests have passed:

{% stepper %}
{% step %}
In `Agent Config → Guardrails`, both Sensitive Data Masking and Tool Execution Approval show as **On** with gear-icon configurations saved.
{% endstep %}

{% step %}
In the Run & Trace log, the PII masking test run shows an opaque token where the SSN was submitted — the raw value `123-45-6789` is absent from the trace.
{% endstep %}

{% step %}
In the Run & Trace log, the tool approval test run shows the credit bureau query gated by an Allow / Deny event, with the outcome recorded.
{% endstep %}

{% step %}
The agent continues to function normally after a Deny — the run does not error out; it simply proceeds without the credit bureau query's output.
{% endstep %}
{% endstepper %}

{% hint style="success" %}
**Best practice:** In a production deployment, configure PII masking and tool execution approval before the agent is published. Guardrails are most effective when they are part of the agent's initial configuration review, not added after the agent is already handling live borrower data.
{% endhint %}

{% hint style="success" %}
**Lab complete.** Confirm every checkpoint above before you move on.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.uptiq.ai/academy/tier-2-core-skills/m07-governance-rbac-ai-gateway-configuration/lab-7-configure-and-validate-policy-based-guardrails.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
