***

title: add_pattern_hint
slug: /reference/python/agents/agent-base/add-pattern-hint
description: Add a speech recognition hint with pattern matching and replacement.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[ref-agentbase]: /docs/server-sdks/reference/python/agents/agent-base

Add a hint with pattern matching and replacement. This allows you to intercept
specific ASR output and rewrite it before it reaches the AI -- useful for correcting
consistent misrecognitions or normalizing variations.

## **Parameters**

<ParamField path="hint" type="str" required={true} toc={true}>
  The hint string to match against ASR output.
</ParamField>

<ParamField path="pattern" type="str" required={true} toc={true}>
  Regular expression pattern to match.
</ParamField>

<ParamField path="replace" type="str" required={true} toc={true}>
  Replacement text to substitute when the pattern matches.
</ParamField>

<ParamField path="ignore_case" type="bool" default="False" toc={true}>
  Whether to ignore case when matching the pattern.
</ParamField>

## **Returns**

[`AgentBase`][ref-agentbase] -- Returns self for method chaining.

## **Example**

```python {6}
from signalwire import AgentBase

agent = AgentBase(name="support", route="/support")
agent.set_prompt_text("You are a helpful assistant.")
# Correct common ASR misrecognition
agent.add_pattern_hint(
    hint="SignalWire",
    pattern=r"signal\s*wire|signal\s*wired",
    replace="SignalWire",
    ignore_case=True
)
agent.serve()
```