# Threshold Agent Response Tuning Exercises

These hands-on exercises help learners understand how to modify and tune assistant behavior in the **Threshold Memory** template by editing key blocks. You'll learn how to change how the agent evaluates, explains, and responds to policy violations.

<details>

<summary>Implementation Support &#x26; Expert Guidance</summary>

Need assistance deploying or customizing this GLIK template for your organization?

Our team offers dedicated coaching and technical walkthrough sessions to ensure successful adoption and alignment with enterprise requirements.

Typical areas of support include:

* Template onboarding and orchestration strategy
* Workflow configuration and logic review
* Memory variable setup and session handling
* Custom integration guidance (e.g. plugins, APIs)
* [Request a Session](https://app.gitbook.com/u/MAmvnLnu7zXBKiXhKYdW9u2kTGF3)

</details>

## Objectives

* Learn which blocks control logic, memory, and response formatting
* Customize fallback behavior and explanation style
* Practice modifying output to match business tone or policy emphasis

***

## Blocks to Explore

| Block Name           | Role in the Workflow                                        | Tips for Editing                             |
| -------------------- | ----------------------------------------------------------- | -------------------------------------------- |
| `Metadata Assigner`  | Sets key memory variables and conversation metadata         | Add tags like `review_required` or `flagged` |
| `Expense Evaluation` | Runs comparison logic (amount vs. threshold, vendor checks) | Modify IF/ELSE branches or add filters       |
| `Fallback Reasoning` | LLM-based explanation block for ambiguous or missing logic  | Change prompt tone or level of formality     |
| `Final Decision`     | Outputs `APPROVED`, `REJECTED`, `ESCALATE` with reason      | Customize wording or formatting              |

## Exercise 1: Change How Violations Are Explained

**🎯 Goal:**\
Make fallback explanations more formal, structured, and compliance-focused — especially when policy violations are detected.

<figure><img src="https://3916444914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDBilw3zq3DIWtwBIyxN9%2Fuploads%2FgwBjPG2FoQk6dveYCtuu%2Fimage.png?alt=media&#x26;token=f3c209d9-808f-4fdc-9cb3-834c997f656f" alt=""><figcaption><p>This block is responsible for explaining whether a receipt is approved or rejected based on policy thresholds. To modify how violations are communicated, click into PROCESS REQUEST and edit the SYSTEM prompt tone — make it more formal, friendly, or tailored to your organization’s communication style.</p></figcaption></figure>

#### ✅ Steps

1. **Open the LLM Block** (currently titled "LLM")
2. **Locate the SYSTEM message** under the `Context` section
3. **Modify the final explanation sentence of the `<Example>` block** to read:

   ```
   Reason: This expense violates policy due to exceeding the threshold without an exception rule. A formal review is required for compliance logging.
   ```

   *(This replaces the current: “No exception rule found. Logged for escalation or review.”)*
4. Optionally, tweak the opening sentence of the SYSTEM prompt to reinforce tone:

   ```
   You are a compliance-focused corporate accountant. Review the receipt and policy to determine validity using formal, transparent justifications.
   ```
5. **Save and re-test** using:\
   `Receipt_4_Only.pdf`\
   \&#xNAN;*(This file contains a suspicious invoice split pattern and exceeds the global threshold)*

{% hint style="info" %}

#### The LLM is used here as a **fallback explanation agent**, especially when the IF/ELSE blocks don’t capture ambiguous or edge-case logic. This edit lets learners experiment with **output tone**, **formality**, and **compliance narrative structure** — without altering business logic.

{% endhint %}

## **Exercise 2: Tone Tuning in the Fallback Reasoning Block**

#### **Goal**

Teach users how to modify the fallback LLM block’s response tone when no policy match is found or ambiguity arises (e.g. split invoices, unclear categories).

***

#### **Why This Matters**

* Helps enterprise users adjust how AI communicates policy enforcement (e.g. strict vs supportive tone)
* Ensures responses align with internal brand or compliance voice
* Enables better UX when agents must reject or escalate expenses

<figure><img src="https://3916444914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDBilw3zq3DIWtwBIyxN9%2Fuploads%2FiMyYxYhRM2guuLyHJoOp%2Fimage.png?alt=media&#x26;token=03d9f161-9103-4493-8559-ae916083d440" alt=""><figcaption><p>To customize how the assistant responds in ambiguous or policy-missing cases, click into this block and edit the system prompt tone. Try adjusting language for different enterprise communication styles (e.g. formal, supportive, strict).</p></figcaption></figure>

#### **Steps**

1. **Open the LLM Fallback Block**
   * Locate the block that handles ambiguous or missing-policy cases (typically tagged `<policy>` and `<receipts>`)
2. **Identify the Current Prompt**
   * Look for something like:

     ```jinja2
     Please review the following receipt in the context of the policy:
     <policy>{{policy_memory}}</policy>
     <receipts>{{receipt_text}}</receipts>
     ```
3. **Modify the Tone**
   * Try rewriting the prompt in one of the following styles:
     * 🔍 **Strict:**

       > “This expense appears to violate corporate policy and will be flagged for immediate rejection.”
     * 💼 **Professional:**

       > “Based on the provided policy, this expense may not be compliant. Please advise.”
     * 🤝 **Supportive:**

       > “This expense might fall outside standard policy. Would you like me to escalate for review?”
4. **Save and Re-run a Test**
   * Use a borderline case like `Receipt_4_Only.pdf`
   * Observe how the assistant’s tone changes based on the new prompt

***

#### ✅ **Success Criteria**

* Output clearly reflects new tone
* System still uses memory-driven policy context
* Learner understands where and how to control fallback behavior

***

## Exercise 3: Add Logic to Escalate Alcohol Violations

#### Goal

Escalate receipts that include alcohol, even if thresholds are not exceeded.

#### Steps

1. Open **Expense Evaluation**
2. Add a condition:

   ```
   If invoice_data.contains_alcohol == true
     → Set `approval_result = ESCALATE`
   ```
3. Upload `Receipt_3.pdf` and confirm escalation

***

## Success Criteria

* Agent response is visibly changed (different tone, tags, or decision path)
* `conversation_notes` reflect updated explanations
* Output is aligned with edited logic and assistant behavior

Try adjusting block logic to fit different organizational policies or tone-of-voice standards!
