> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://poly-ai.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://poly-ai.ferndocs.com/_mcp/server.

# Tutorial: Response control

> PolyAcademy Level 2 – Use post-generation controls to fix preambles, prevent loops, and enforce brand tone.

**Level 2 – Lesson 4 of 8** – Master response controls to regulate agent output and enforce tone.

> **Lesson**
>
> Level 2 · Intermediate · 15 min

[Advanced voice settings](/agent-studio/voice/advanced-settings) regulate the agent's *own output*. They run **after** the model generates text and **before** anything is spoken or sent. Useful for tone, safety, and flow – easy to misuse if patterns are too broad.

## What response controls are

Response Controls are **string- or regex-based rules** that inspect the agent's generated response.

#### Halt responses

Prevent specific phrases from being spoken

#### Trigger routing

Activate corrective or fallback behavior

#### Log patterns

Track unwanted patterns for analysis

#### Enforce tone

Maintain brand voice consistency

Response controls are not about what the *user* says – they are about what the *agent* says.

## Which tool to use for which problem

```mermaid
flowchart TD
    A[Unwanted agent behavior] --> B{What type of problem?}
    B -->|ASR mishears user| C[Use ASR tools / Keyphrase Boosting]
    B -->|Wrong topic retrieved| D[Fix Managed Topic name or sample questions]
    B -->|Agent says something it shouldn't| E[Use Response Controls]
    E --> F{Should phrase NEVER appear?}
    F -->|Yes| G[Halt – set Say phrases: TRUE]
    F -->|No, just monitor it| H[Log – set Say phrases: FALSE]
    G --> I{Needs a fallback action?}
    I -->|Yes| J[Attach a function]
    I -->|No| K[Done]
```

## When to use response controls

Use response controls when you want to fix or prevent:

#### Redundant preambles

**Examples:**

* "Let me check that for you…"
* "Please hold while I look into this…"

#### Looping behavior

**Examples:**

* Repeating the greeting mid-call
* Restarting the conversation after silence

#### Off-brand phrasing

**Examples:**

* Overly apologetic language
* Internal system explanations

#### Unsafe output

**Examples:**

* Speculation
* Policy invention
* Meta commentary about limitations

- If the issue is about *recognition*, use ASR tools
- If the issue is about *retrieval*, fix the FAQs
- If the issue is about *how the agent speaks*, use Response Controls

## How response controls work

#### LLM generates response

The model creates text based on context and prompts

#### Response Controls scan output

Regex patterns are evaluated against the generated text

#### Action taken if matched

* The response may be halted
* A function may be triggered
* The event may be logged for analytics

Controls are evaluated in real time and apply consistently across Chat and Call.

#### Check your understanding

#### Your agent keeps saying 'Let me check that for you' before every response, creating awkward pauses in voice calls. Which tool should you use to fix this?

* Managed Topic sample questions
* Keyphrase Boosting in Global ASR
* A Response Control with Say phrases set to TRUE
* A Transcript Correction rule

**Answer:** A Response Control with Say phrases set to TRUE

This is an agent output problem – the agent is generating filler phrasing. A Response Control with 'Say phrases: TRUE' will halt the unwanted phrase before it reaches the user.

## Core fields

Each Response Control includes:

#### ID

A short, descriptive identifier used for tracking and debugging.

#### Description

Optional, but strongly recommended. Explains *why* the rule exists.

#### Regular Expression

The exact pattern that will be matched against agent output.

#### Say phrases (Boolean)

Despite the name, this field controls **halting**, not allowing:

* **ON (Halt)**: matching output is **blocked** before it reaches the user
* **OFF (Log)**: matching output is **allowed through** but recorded for analytics

#### Function (optional)

A fallback action to run when the phrase is detected.

## Best practices

#### Start narrow

Broad patterns are hard to debug and can suppress valid responses.

`.*sorry.*`

`\b(sorry for the inconvenience|apologies for the delay)\b`

#### Target symptoms

Encode *specific phrases* you have observed, not abstract concepts.

"Prevent the agent from being verbose"

`\b(let me explain how|to give you some background)\b`

#### Prefer halting

If a phrase should *never* appear, halt it rather than replacing it.

#### Test thoroughly

Verify in both Chat and Call to catch unnatural truncation.

## Common use cases

#### Removing preambles

LLMs often add filler before answering or executing actions.

**Example unwanted output:**
"Let me check that for you. Please hold…"

**Suggested control:**

* **ID:** `flow_redundancy_cutoff`
* **Regex:** `\b(let me check|please hold|one moment while I)\b`
* **Say phrases:** TRUE

**Result:** The agent proceeds directly to the answer or action.

#### Preventing greeting loops

Sometimes the agent restarts the conversation mid-call.

**Example unwanted output:**
"Thank you for calling Hopper…"

**Suggested control:**

* **ID:** `greet_loop`
* **Regex:** `(thank you for calling|you have reached|hi thanks for calling)`
* **Say phrases:** TRUE

You can optionally attach a function that routes to a recovery flow instead of restarting.

#### Blocking dead ends

Agents sometimes respond with unhelpful refusals instead of routing.

**Example unwanted output:**
"I don't have information about that."

**Suggested control:**

* **ID:** `default_no_info`
* **Regex:** `I don't have (any|specific)? information`
* **Say phrases:** TRUE
* **Function:** `prompt_OOS_Check`

**Result:** Instead of dead-ending, the agent routes to out-of-scope handling.

#### Brand tone enforcement

Prevent phrasing that violates brand voice.

**Example unwanted output:**
"Unfortunately, I'm unable to…"

**Suggested control:**

* **ID:** `tone_softener`
* **Regex:** `\b(unfortunately|sadly|regret to inform)\b`
* **Say phrases:** TRUE

**Result:** Forces the agent to rephrase without negative framing.

## Logging-only controls

Not all controls need to halt output. You can use Response Controls purely for **monitoring**.

#### Example: tracking hedging language

* **ID:** `hedge_language_monitor`
* **Regex:** `\b(might|maybe|possibly)\b`
* **Say phrases:** FALSE

Tracks hedging frequency without disrupting users.

## Testing and verification

After adding or updating a Response Control:

#### Test in Chat

* Confirm the phrase no longer appears
* Ensure the response still completes cleanly

#### Test in Call

* Listen for unnatural truncation
* Ensure turn-taking still feels natural

#### Review Conversation logs

* Check whether the rule is triggering too often
* Look for false positives

## Common mistakes

> **Warning**
>
> **Avoid these pitfalls:**
>
> * Using overly broad regex patterns
> * Blocking phrases that appear in legitimate answers
> * Using Response Controls to fix retrieval problems
> * Forgetting to test in voice after chat validation

#### Check your understanding

#### What do Response Controls regulate?

* What the user is allowed to say
* How ASR processes audio input
* The agent's own generated output
* Which FAQs can be triggered

**Answer:** The agent's own generated output

Response Controls run after the LLM generates a response, before it's spoken or sent. They regulate the agent's own output – not what the user says or how speech is transcribed.

## Pronunciations (separate feature)

#### Response Controls

Affect *what* is said

#### Pronunciations

Affect *how* it is spoken

Use **Pronunciations** when:

* Names are mispronounced
* Numbers need pacing
* Domain terms require IPA or SSML guidance

> **Note**
>
> Do not use Response Controls to solve pronunciation issues.

Response Controls are a surgical tool – the final layer of polish, not the first fix.

## Try it yourself

#### Challenge: Write a response control

You notice the agent frequently says "Let me look into that for you" before answering – which creates an awkward pause in voice calls.

Write the full Response Control configuration:

1. ID
2. Description
3. Regex
4. Say phrases setting

#### Hint

Write the regex to match the specific phrase you observed, not a broad pattern. Start as narrow as possible – you can always widen it if needed.

#### Example solution

* **ID:** `filler_preamble_cutoff`
* **Description:** Prevents the agent from saying "Let me look into that for you" before responding – this creates latency and sounds unnatural in voice.
* **Regex:** `\blet me (look into|check) that for you\b`
* **Say phrases:** TRUE

#### Check your understanding

#### What's the difference between Halt and Log in Response Controls?

* Halt monitors the phrase; Log blocks it
* Both do the same thing but at different latency costs
* Halt blocks the response; Log lets it through while tracking it
* Halt applies globally; Log applies per conversation

**Answer:** Halt blocks the response; Log lets it through while tracking it

If a phrase should never appear, Halt it – the response is blocked before reaching the user. Logging lets the phrase through while recording it, which is useful for monitoring but not for enforcement.

#### [← Previous: Return values](/academy/poly-academy/poly-academy-level-2/tool-return-values)

Lesson 3 of 8

#### [Next: Audio management →](/academy/poly-academy/poly-academy-level-2/audio-management)

Lesson 5 of 8