Items marked (preview) in this article are currently in public preview. This preview is provided without a service-level agreement, and we don’t recommend it for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
Prerequisites
- A voice-based agent. See Quickstart: Create a voice-based prompt agent.
- Familiarity with the agent definition fields in Configure a voice agent.
Structure instructions in sections
Voice agent instructions work best with a consistent structure. Use these sections, in order:
This structure keeps related rules together, which makes the instructions easier to tune later. When a caller reports a problem, you usually change one section rather than rewriting the prompt.
Here’s an example of each section:
Write the Personality section
The Personality section defines who the agent is and how it carries itself. In a voice agent, personality comes through in word choice and pacing, so keep it to a name, a role, and a few concrete traits:- Give the agent a name and a role tied to your scenario, such as a named assistant for a support line.
- Choose a few consistent traits, such as warm, patient, and precise, rather than a long list.
- State what the agent is confident about and what it’s honest about not knowing.
- Make it a rule that the agent never guesses; it looks up information or hands off.
Write the Environment section
The Environment section tells the agent where the conversation happens and what it can and can’t know. Spell out the constraints of the channel, because the model can’t infer them:- Say the agent is on a live call and the caller can only hear it, with no screen to read.
- Note that the agent doesn’t know who the caller is until they verify.
- Establish that the agent’s tools are its only source of truth.
Write the Tone section
The Tone section does most of the work in a voice agent. Cover these points explicitly, because a model won’t infer them from the fact that the channel is audio:- Reply length. State a limit, such as one or two sentences. Then pair it with
max_output_tokenson the agent definition so the limit is enforced rather than merely requested. - No markup. Ban markdown, bullet points, and headings. A synthesizer reads asterisks aloud or drops them, and neither result is what you want.
- Spoken numbers. Tell the agent to speak numbers, currency, and identifiers as words, and to group long digit strings.
- Turn-taking. Tell the agent to ask one question at a time and to stop after asking. Compound questions cause callers to answer only the last part.
- Acknowledgments. Short fillers such as “Got it” make pauses feel intentional.
Write the Goal section
The Goal section defines success as a short numbered sequence the caller can follow by ear, with one outcome per call. Make verification and confirmation their own steps, because spoken confirmation is a caller’s only chance to catch a mistake. End with a closing step that calls theend_conversation tool so completed calls don’t idle.
- Find out what the caller needs.
- Verify identity before anything sensitive.
- Handle the request one step at a time.
- Confirm the outcome out loud, then close.
Write the Guardrails section
Voice sessions are harder to supervise than text sessions, so write the constraints as rules rather than as preferences. Cover at least these three:- Verify identity before disclosing anything sensitive.
- Stay in scope, and refuse requests outside it.
- Hand off to a human on request, on failed verification, or on anything the agent can’t complete.
Use structured inputs instead of hardcoded values
When the same instructions serve several brands, regions, or business units, use Handlebars placeholders and declare a matchingstructured_inputs entry for each one. The service renders the template once per session, before the session starts.
structured_inputs entry. If one is missing, the session fails to start rather than speaking an unresolved placeholder to the caller. Give each entry a description, and mark it as required when the caller must supply it at session time.
Other agent tuning
Tune audio settings without instructions
Some behavior that sounds like a prompt problem is actually an audio setting. Check these settings before you rewrite instructions:
See Configure a voice agent for the full set of options.
Write tool descriptions for a spoken flow
Tool descriptions influence latency as well as accuracy, because a wrong tool call costs a full extra turn that the caller hears as a pause.- Write one clear sentence per tool that says when to use it, not just what it does.
- Describe each parameter in the terms a caller would speak. An order number that callers read as “the number on the email” should say so.
- Keep tool inventories small. Every attached tool adds context to every turn.
- Add the
end_conversationsystem tool and say in the Goal section when to use it, so completed calls end cleanly.
interim_response rather than instructing the agent to announce waits. A static_interim_response fills the gap with no extra model call.
Write the greeting separately
Don’t put the opening line ininstructions. Use the greeting field so the opening turn is deterministic and doesn’t wait on a model call.
A good greeting does three things in one or two sentences: it identifies the organization, it names two or three concrete capabilities, and it ends with an open question.
template mode when the opening must be predictable or preapproved, which is common in regulated scenarios. Use llm_generated mode when the opening should adapt to session context, and accept the added latency on the first turn.
Validate your changes
Each update creates a new immutable agent version, so you can compare versions directly:- Create a version with the revised instructions.
- Connect to that version and run the same set of spoken scenarios you used before, including one interruption and one tool failure.
- Compare turn latency and interruption rate between versions in your traces.
- Score the transcripts with agent evaluators for intent resolution and task adherence.
- Promote the version when it wins, or roll back by pointing the endpoint at the previous version.