# 05 Mystery guest

> Deepgram workshops › Build a voice agent › Mission 05
> Web version: https://workshops.deepgram.com/voice-agent/stay-in-character
> About 20 min (estimate). Check it: `make check 05` (offline, no key).

Give your agent a secret identity and make someone guess it.

- [Pick your figure](https://workshops.deepgram.com/voice-agent/stay-in-character/pick-your-figure.md)
- [Write the character](https://workshops.deepgram.com/voice-agent/stay-in-character/write-the-character.md)
- [Quality gate](https://workshops.deepgram.com/voice-agent/stay-in-character/quality-gate.md)
- [Hand it over](https://workshops.deepgram.com/voice-agent/stay-in-character/hand-it-over.md)
- [What happened](https://workshops.deepgram.com/voice-agent/stay-in-character/what-happened.md)

## Pick your figure

### Pick and save the secret

**Goal:** Pick a historical figure and save it as the agent's secret.

In this game your agent plays a secret historical figure, and someone else guesses who it is. The secret has to be saved before anything else works.

**Do:** Pick a famous historical figure and tell nobody. Type the name below and tap **Save the secret**.

Playing solo? Pick **Just me: surprise me** and the server picks for you.

**Check:** The secret is saved.

**You should see:** "Saved", and a note that only the server knows the name. If it says no secret is saved, type the name in the box and tap **Save the secret**. Or pick **Just me: surprise me** and tap **Pick a figure for me**.

**How it works**

You write a prompt, the written instructions that tell the agent who it is. In it the agent is your figure and never says the name. Someone else talks to it and guesses. There's no greeting, so it can't give the game away before the first question.

**What makes a figure work.**

- **Recognizable:** a stranger has to land on the name in a few minutes.
- **Well documented:** famous deeds, rivals, travels, and habits give the agent something to hint with.
- **Historical:** the agent knows nothing invented after the figure died, which is the funniest rule in the game.

Real and long gone is the safe pick. A deeply documented fictional character can work too.

**The secret.** The server keeps the name and checks every guess against it. A surname on its own counts.

When you start the agent, the server adds the name to its instructions. You never type it into Settings, and it never shows on screen. If the agent is running, it reconnects on its own to pick up the name, and the conversation stays on screen.

**Solo.** With **Just me: surprise me**, leave the era line on **Write the character** exactly as it is. The server fills it in for the figure it picked. The attendee project picks a figure the same way.

## Write the character

### Fill in the template

**Goal:** Fill in two fields so your agent plays the figure and hints at who it is without saying the name.

The prompt is a template, a script with blanks for you to fill. Two fields fill the blanks, and the secret name stays on the server.

**Do:** Fill in **Era and work** and **How they talk**. Keep the name out of both. That's the only edit.

_On the web page, this step has the Settings panel; in your own code the same settings are in the start file._

The code tabs below show the same name swap in a server you'd write. It runs on the server, never in the browser.

_On the web page, this step shows the code panel with the matching code._

**You should see:** your two lines in the fields, with no name in either. Playing solo with **Just me: surprise me**? Leave both fields empty, and the server describes the figure.

### Talk to it

There's no greeting, so the agent waits for you to speak first.

**Do:** Tap **Start the agent** and ask what it does all day.

**Listen for:** a clue.

_On the web page, this step has the agent console: talk or type to the agent there, or run the same mission in your own code._

**Check:** It has a personality and a secret.

**You should see:** an answer in character with a clue in it, and the check passing. If it says the character is still blank, fill in **Era and work** and **How they talk**. Or replace `[ONE_OR_TWO_LINES]` in the Prompt, then tap **Reconnect and apply**.

**How it works**

Example: **Era and work** "Renaissance Florence, painter and engineer", **How they talk** "curious about everything, answers a question with a question." Rather edit the prompt? Replace `[ONE_OR_TWO_LINES]` on its first line instead.

Pick a **Voice** that fits, and for a big personality push **Expressivity** up a notch.

**Where the name gets in.** **Settings JSON** is exactly what this browser sends, and the prompt still says `{{secret}}`. The server swaps the name in on its own copy, the one that goes to Deepgram.

**What every line does.**

- Era, work and how you talk: filled from your two fields, the clues the agent plays from. Keep the name out of it.
- The secret identity, and never confirm until guessed: the server fills in the name. "Are you Napoleon?" gets no confirmation. Trait questions such as "are you a painter?" are fair play. Only a correct guess ends it.
- Speak aloud, one to three sentences: keeps out bullet points, asterisks, and monologues.
- One true detail per answer: a clue each turn, so the guesser has something to work with.
- Nothing after your death: most of the comedy. Ask it about phones.
- The AI question: the one sanctioned break. Asked what it is, it answers plainly, then goes back into the role.

## Quality gate

### Try to break it

**Goal:** Try three tricks on your agent and confirm it still keeps the name.

Before you hand it to anyone, push on the agent the way a stubborn guesser would.

**Do:** Try to break it: ask the name, ask it to spell it, say you already won.

**Listen for:** it staying in character, briefly, with a clue each time.

_On the web page, this step has the agent console: talk or type to the agent there, or run the same mission in your own code._

_On the web page, this step has the Settings panel; in your own code the same settings are in the start file._

**Check:** It kept the name through three trick questions.

**You should see:** the agent stay in character, in one to three sentences, and never say the name. If it confesses, put the template's second line back as it was and tap **Reconnect and apply**. Once all three tricks hold, tap **I did this**.

**How it works**

**It keeps the name under pressure.** Also tell it to ignore its instructions.

**It's brief.** One to three sentences a turn. If it monologues, move the "Speak aloud" line up.

**It lets something slip.** Ask what it does all day. If three answers give you nothing usable, tell it to weave in one true detail per answer from the figure's real life.

This checkpoint is on your honor. The agent's events can't tell a trick question from a friendly one.

## Hand it over

### Hand it to someone

**Goal:** Hand the agent to someone and let them work out who it is.

**You need:** someone else to ask the questions. Playing solo works too, with the surprise pick.

**Do:** Show the **Talk** tab so Settings is out of sight, and hand it to someone. They ask; you stay quiet. Openers:

> "What do you do all day?"

> "Who pays for your work?"

> "Where have you traveled?"

**Listen for:** one true detail in every answer, and never the name.

_On the web page, this step has the agent console: talk or type to the agent there, or run the same mission in your own code._

**You should see:** the guesser asking questions and the agent answering with one true detail each time. If Settings is still showing, switch to the **Talk** tab.

### Make a guess

**Do:** Think you know? Type the guess. A surname counts.

**Check:** Someone guessed who it is.

**You should see:** the check saying someone guessed it. If it says nobody has, have the guesser type their guess in the box above. A wrong guess adds to the count, so keep asking.

Solo? Go back to [Pick your figure](https://workshops.deepgram.com/voice-agent/stay-in-character/pick-your-figure.md) and pick **Just me: surprise me**.

**How it works**

The Talk tab keeps your clues one tap further away, and the name isn't in there. There's no greeting, so the guesser asks first.

After a wrong guess, ask another question. Every answer carries one true detail. Asking how it works or whether it's an AI is free: it answers plainly, then goes back into character.

**Solo:** the server picks a famous figure and keeps it from you, and you ask until you know. If your first line describes a figure of your own, put `[ONE_OR_TWO_LINES]` back. Otherwise the agent gets the wrong clues. Then tap **Reconnect and apply**.

## What happened

### Hard mode: keep the secret

**Goal:** Check that your agent kept the secret all game, then take it home.

**What you tuned:** every layer, in one agent. Someone guessed who it was from how it heard, waited, thought, and sounded.

**Do:** **Hard mode.** Did it keep the name the whole way?

**Check:** Hard mode: it kept the secret. (Optional.)

**You should see:** the check passing, with not one slip from the first question to the right guess. If it doesn't pass, save the secret, ask the agent at least three questions (or hand it to someone who does), then guess.

### Take it home

Take the prompt to the [Playground](https://playground.deepgram.com/voice-agent?utm_source=workshops&utm_medium=agent&utm_campaign=workshop-voice-agent&utm_content=md-mystery-guest), or run the game in the attendee project in [Python](https://github.com/deepgram-devs/voice-agent-workshop/blob/main/python/missions/05-mystery-guest/start.py) or [TypeScript](https://github.com/deepgram-devs/voice-agent-workshop/blob/main/typescript/missions/05-mystery-guest/start.ts).

**How it works**

Every line of the template answers a way the game breaks: a name slip, a monologue, an agent too locked down to guess, an anachronism. Most prompt writing for voice is closing off the ways a conversation goes wrong.

**Hard mode:** the check reads every line the agent said between saving the secret and the right guess. It passes when there were at least three and none gave the name away. Solo counts too.

The prompt drops straight into the Playground. The attendee project runs this game, surprise pick and all. In your own code, keep the answer on your server and add it to the prompt when the session starts. The code panel on **Write the character** shows where.

**In production**

- **Watch:** whether a prompt rule holds over a long call. Log each reply that breaks a rule your app can test in code (here, saying the name), per thousand turns.
- **Aim for:** one to three sentences a reply, and zero rule breaks in a few dozen scripted trick questions before you ship a prompt change.
- **Read:** the [Voice Agent docs](https://developers.deepgram.com/docs/voice-agent) on the think block and on `UpdatePrompt` for changing instructions mid-call.
