Optimizing your prompts for any LLM is primarily a process of trial and error. Prompt changes should always be tested against an evaluation dataset that reflects production usage. Treat the patterns below as starting points, not final answers.
What’s inside
Prompt Structure
Section ordering, XML tags, and dynamic prompt injection.
General Techniques
Personas, few-shot examples, verbosity, and guardrails.
Voice Agents
Markdown suppression, pacing, and pronunciation rules.
Tool-Calling Agents
Sequential gathering, confirmations, and state machines.
Search & Research
Query construction, recency, grounding, and synthesis.
Code Agents
Style enforcement and agentic coding workflows.
Prompt Structure
Instruction organization
We recommend structuring prompts in this order:1
Persona, Style, Goal
Who the agent is, how it should sound, and what it’s trying to accomplish.
2
Knowledge Base, Tools, References
Grounding content, tool definitions, and any reference material.
3
Current Task Instructions
The active instruction for this turn or workflow.
4
Few-Shot Examples
Positive and negative examples demonstrating desired behavior.
5
Critical Rules
Non-negotiable constraints. Place these last — Mercury weights recent context heavily.
XML tags for long system prompts
For multi-section prompts, XML tags help Mercury parse which part of the prompt governs which behavior.Dynamic system prompt injection
For multi-turn agents, you can rebuild the system prompt each turn with the current state instead of relying on conversation history alone.General Techniques
Role description
Describe Mercury’s persona and goal for your use case. This is where you set who the assistant is, what it’s trying to accomplish, and how it should sound while doing it.- Warm and encouraging
- Precise and formal
- Playful and energetic
Self-validation checklist
For stricter instruction-following, give Mercury a list of specifications to silently check its draft response against. The model uses its reasoning scratchpad to do a final review pass before answering.Few-shot examples
For any qualitative preferences (tone, format, confirmation style), including examples in User/Assistant dialog form can work better than written descriptions. This is particularly important when you want the model to follow a templated response or adhere to a specific standard. Include both positive and negative examples in the same prompt, and label them clearly so the model knows which behavior to follow and which to avoid:System prompt
Verbosity and style
To control the verbosity of Mercury’s final output, provide guidance as to the desired verbosity and output style:Specificity
Vague
“Be professional.”
Specific
“Address the caller by first name after they’ve been authenticated. Use complete sentences. Do not use contractions.”
Guardrails and scope
To keep Mercury on task in a focused use case:Persona and character
When you define a persona, you can list forbidden openers in the same place. This is a simple way to remove sycophantic filler.Clarification before acting
When a request is underspecified, ask Mercury to pick the single most important missing detail rather than dumping a checklist on the user:Voice Agents
Voice has its own constraints: no markdown rendering, spoken number formats, natural pacing, and tight latency budgets. The rules below specifically address those.
Suppress markdown
By default, Mercury tends to present information in a visually organized manner with bolded text, bullets, headers, and tables — none of which translate well to speech. You can instruct it to respond in a conversational manner.- Before ❌
- After ✅
Here’s a quick overview of our services:
- General care: cleanings, exams…
- Cosmetic: whitening, veneers…
One question at a time
In voice use cases, it can be overwhelming for a user to have to answer multiple questions at once. You can instruct the model to ask one question at a time.- Before ❌
- After ✅
Could you please provide your full name, preferred date, preferred time, and the service you’d like?
Number and format pronunciation
Spell out how each data type should be read aloud. TTS engines vary, and Mercury follows the format you give it.Pronunciation rules
Phonetic spell-back alphabet
When Mercury needs to spell a name or code aloud:Spell-back alphabet
Multilingual
For multilingual applications, you may still write the system prompt in English, but you can instruct Mercury to match its response to the user’s language.Tool-Calling Agents
Sequential information gathering
For multi-step data collection, structure the prompt around what’s already collected versus what’s still missing.Few-shot examples for tool selection
When the model has access to multiple tools, written instructions alone often aren’t enough to get reliable routing — tool-selection behavior is sensitive to small phrasing differences. Few-shot examples in the system prompt are one of the highest-leverage interventions when the model is calling the wrong tool, calling tools it shouldn’t, or skipping tools it should call. Show 2–3 examples of correct routing, plus one or two negative examples where no tool call is needed:Limiting unnecessary tool calls
When speed matters more than exhaustive search:Tool call confirmation
For tools with irreversible effects (sends, payments, deletions), make Mercury confirm before acting.
State machine / workflow transitions
For complex flows with multiple stages, frame them as transition conditions:Search and Research Agents
Narrow, sequential queries
Mercury’s sequential tool calling allows it to run focused queries, examine the results, and iteratively refine.Example: highest-rated late-night Italian restaurant
Example: highest-rated late-night Italian restaurant
User: “What’s the highest-rated Italian restaurant in my neighborhood that’s open late?”
1
Broad enumeration
Query 1:
Italian restaurants in Mission District San Francisco → ~30 results.2
Narrow by quality
Query 2:
top rated Italian Mission District → 5 with 4.5+ stars.3
Check the top candidate
Query 3:
[top result] hours → Closes at 9pm. Doesn’t match “open late.”4
Check the next candidate
Query 4:
[second result] hours → Open until 11pm. Match.5
Synthesize
Recommend the second result.
Query construction
To produce optimal retrieval, the model should focus on high-signal words when querying. This will produce the best set of retrieved sources for the model to reason over.Recency
Ideally, the model should prefer sources and documents that are more recent — especially for recent events. The model should reason that more recent sources are likely higher signal.Source grounding
The model should be able to map its results and reasoning back to specific sources it received from the knowledge base.Structured knowledge base injection
Use XML tags so the model can clearly tell where the knowledge base ends and the prompt begins.Disambiguation
User queries are often ambiguous in ways the model can silently resolve in the wrong direction. The model should surface the assumption rather than commit to one interpretation invisibly.Source quality and conflicts
The model should be able to weigh the veracity and relevance of sources against one another, and should take this into account when executing a query plan.When not to search
The model should not always bias towards using knowledge-base search capabilities when it already knows, in its weights, the answer to the user’s question with high certainty.Synthesizing the answer
The model should reason over the returned search results and produce a high-signal, source-grounded answer. It shouldn’t dump all sources or lead with them — the answer should be direct and easily understood.Code Agents
Enforcing code style
Add clear instructions of how you want code to be written in order for the model to adhere to your preferred style.Code agent with tool use
If relevant, describe the complete agentic workflow (tool-calling, verification, retries, etc.) to your model.1
Acknowledge
Send a short acknowledgment describing your first action.
2
Execute sequentially
Run tools in order — read before writing.
3
Verify
After making changes, run the tests to confirm correctness.
4
Diagnose and retry
If tests fail, read the error, diagnose, fix, and re-test.
This guide reflects observed Mercury 2 behavior as of May 2026. Test techniques on your specific prompts before deploying.