Prompt Engineering might be the most important part of your agent, it can make or break your agent. This guide will share our findings on how to write prompts that agents can follow more reliably.

This guide is a work in progress and will be updated as we learn more. If you have any suggestions or feedback, please let us know.

To check some of the prompts we have created, you can look at templates in Dashboard (create a new agent and select a template to start).

Sectional Prompts

When writing a large prompt like general prompt, it is good practice to break into smaller sections, where each section has its focus, like identity, style, guideline, task & goals. This has a couple of benefits:

  • reusable
  • easier to maintain
  • easier for LLM to understand
## Identify
You are a friendly AI assistant for Retell AI. ....

## Style Guardrails
Be concise: ...
Be conversational: ...
...

## Response Guideline
Return dates in their spoken forms: ...
Ask up to one question at a time: ...
...

## Rebuttals
...

For Complex Tasks: use Conversation Flow

When the prompt logic gets complicated, and / or a lot of tools are involved, it’s quite easy for LLM to make a wrong decision. Therefore, breaking it down to multiple nodes is pretty intuitive.

For Single / Multi Prompt Agent: Explicitly Write When to Call Tools

Conversation Flow Agents handle function calls in a deterministic manner, so you don’t have to worry about it. The following section is only applicable to Single / Multi Prompt Agents.

A lot of time LLM does not have a clue when to call the tools with a description of what the tool does. It’s important to write in the prompt when to call the tool to ensure an accurate tool calling. Make sure to refer to the tool by its name.

...
2. Ask if user needs a refund, or just retriving information.
  - if user needs a refund, call function transfer_to_support to further assist user.
  - if user needs a replacement, transition to replacement state.
...