Skip to content
AgenticAIWiki
  1. Learn
  2. Part 2
  3. 11. Explicit criteria, roles and XML tags
  4. 11.7

Lesson 11.7 · 7 of 7 · 6 min read · Reviewed 24 Nov 2026

Role prompting: when personas help and when they don't

By the end, you can

  • Decide whether a persona is likely to help a given task, and test it with a small eval.
  • Replace fake credentials with a stated lens, audience and criteria.

Lesson 11.3 showed how a role and an audience shape an answer. This lesson asks the harder question: does a persona actually make the output better, and how would you know?

What a persona changes, and what it does not

A line such as “You are a security reviewer” nudges the model towards a set of words, concerns and habits that appear near that phrase in its training data. That can change:

  • Tone and register: formal, blunt, gentle, technical.
  • Focus: a security reviewer lists injection risks; a performance reviewer lists slow loops.
  • Format habits: a reviewer writes findings, a teacher writes explanations.

It does not change what the model knows. A model that cannot do a calculation will not learn it because you called it a mathematician. Research on thousands of factual questions found that adding personas to the system promptSystem prompt: Instructions passed in the top-level system field that set the model’s role, rules and context for the whole conversation. gave no reliable accuracy gain over no persona at all, and which persona did best looked close to random. Other work found role-play framing helped some reasoning tasks. Both can be true: the effect depends on the task and the model, which is exactly why you measure it.

Expertise framing versus fake credentials

Fake credentials Expertise framing
“You are a world-class lawyer with 30 years of experience and many awards.” “Review this lease as a tenant’s adviser. Flag clauses that cost the tenant money or limit when they can leave.”
Adds status, not information Names a lens, a side and a task
Can raise confidence without raising accuracy Gives criteria you can check

Credentials have a hidden cost: a model told it is a top expert may sound more certain, hedge less and be wrong just as often. If you want caution, say so: “If the lease is unclear, say so and quote the clause.”

Audience roles

Often the most useful role is not the speaker but the reader. “The reader is a first-year nurse” tells the model what to define, what to skip and how long to be. If you only add one role line, make it the audience.

Test it with a small eval

Treat a persona like any other prompt change (chapter 16):

  1. Fix a test set: 30 to 50 real questions with a pass rule for each.
  2. Run it twice: once with the persona, once without. Keep everything else the same.
  3. Compare pass rates, and run each version more than once to see the noise.
  4. Keep the persona only if it wins by clearly more than the run-to-run spread, or if it wins on a criterion you care about, such as tone, without losing accuracy.
                   pass rate   run 1   run 2   run 3
no persona            74%       73%     76%     74%
"senior auditor"      75%       77%     72%     76%

Here the persona’s gain of one point is smaller than the spread between runs. It is noise. Drop it, or keep it only for tone if a tone check shows a real gain.

Common mistakes

  • Judging by feel. Persona answers often sound better. Grade against the pass rules, not the vibe.
  • Persona instead of criteria. “You are an expert editor” is weaker than “Cut sentences over 25 words and remove filler.”
  • Persona drift. A persona that tells jokes in a support bot can leak into answers where jokes are wrong. Check the edge cases too.
  • Testing one example. A single good answer proves nothing. Use the whole test set.

Key points

  • A persona changes tone, vocabulary and what the model pays attention to. It does not add knowledge the model lacks.
  • Expertise framing names a lens and a task. Fake credentials, such as years of experience or awards, add nothing to act on.
  • Audience roles usually move the output more than the speaker's role does.
  • Keep a persona only if it wins on a fixed test set by more than run-to-run noise.
Hands-on labRuns in the Playground

Test a persona against a baseline

Decide with an eval, not by feel, whether a persona line improves answers.

You will have: A script that runs a 40-case test set three times per prompt and prints pass rates, the gain, the noise and a verdict for each persona.

Steps

  1. Run the starter: it runs each prompt once and prints a single pass rate.
  2. Make run_eval repeat the test set three times so you can see the run-to-run spread.
  3. Compute each persona's mean gain over the no-persona baseline and the noise (the largest max minus min across runs).
  4. Print a verdict: keep it, drop it, or no real difference.
  5. Read the credentials reply that fails and say why it fails the pass rule.

Done when

  • Each prompt shows three pass rates.
  • The credentials persona gets the verdict drop it.
  • The audience and criteria line shows no real difference in accuracy.

Open in the Playground No API key needed.

Starter code (Python)
# Test whether a persona helps, with a fixed test set and repeated runs.
import random

QUESTIONS = [(f"What is {a} + {b}?", a + b) for a, b in [(17, 26), (38, 45), (59, 64), (12, 99), (73, 28), (46, 57), (81, 19), (34, 68), (27, 75), (62, 39)] * 4]
QUESTIONS = [(q + f" (case {i + 1})", ans) for i, (q, ans) in enumerate(QUESTIONS)]  # 40 cases

PROMPTS = {
    "no persona": "",
    "credentials": "You are a world-renowned mathematician with 30 years of experience.",
    "audience + criteria": "The reader is a cashier. Reply with the number only.",
}


def model(system, question, run):
    # Simulated model: the persona never changes what it knows (about 74% correct),
    # but grand credentials make it add a confident preamble some of the time.
    rng = random.Random(f"{question}|{run}")
    right = rng.random() < 0.74
    a, b = [int(x) for x in question.split("?")[0].split("is ")[1].split(" + ")]
    value = a + b if right else a + b + rng.choice([-10, -1, 1, 10])
    style = random.Random(f"{system}|{question}|{run}")
    if "renowned" in system and style.random() < 0.3:
        return f"As a leading expert I can say with complete certainty, after careful thought, that the answer is clearly {value}."
    if "number only" in system:
        return str(value)
    return f"The answer is {value}."


def passes(reply, expected):
    # Pass rule: the right number, in at most 12 words.
    words = [w.strip(".,") for w in reply.split()]
    return str(expected) in words and len(words) <= 12


def run_eval(system, runs=3):
    # TODO: run the whole test set `runs` times (run = 0, 1, 2) and return a list of pass rates in %.
    # For now it runs once, which hides the run-to-run noise.
    ok = sum(passes(model(system, q, 0), expected) for q, expected in QUESTIONS)
    return [round(100 * ok / len(QUESTIONS))]


base = run_eval(PROMPTS["no persona"])
print("no persona:", base)
for name in ["credentials", "audience + criteria"]:
    rates = run_eval(PROMPTS[name])
    print(f"{name}: {rates}")
    # TODO: compute the gain in mean pass rate over the baseline, and the noise (the largest
    #       max - min spread across runs). Print a verdict: "keep it" if the gain beats the noise,
    #       "drop it" if it loses by more than the noise, otherwise "no real difference".
Show a solution
# Test whether a persona helps, with a fixed test set and repeated runs.
import random

QUESTIONS = [(f"What is {a} + {b}?", a + b) for a, b in [(17, 26), (38, 45), (59, 64), (12, 99), (73, 28), (46, 57), (81, 19), (34, 68), (27, 75), (62, 39)] * 4]
QUESTIONS = [(q + f" (case {i + 1})", ans) for i, (q, ans) in enumerate(QUESTIONS)]  # 40 cases

PROMPTS = {
    "no persona": "",
    "credentials": "You are a world-renowned mathematician with 30 years of experience.",
    "audience + criteria": "The reader is a cashier. Reply with the number only.",
}


def model(system, question, run):
    # Simulated model: the persona never changes what it knows (about 74% correct),
    # but grand credentials make it add a confident preamble some of the time.
    rng = random.Random(f"{question}|{run}")
    right = rng.random() < 0.74
    a, b = [int(x) for x in question.split("?")[0].split("is ")[1].split(" + ")]
    value = a + b if right else a + b + rng.choice([-10, -1, 1, 10])
    style = random.Random(f"{system}|{question}|{run}")
    if "renowned" in system and style.random() < 0.3:
        return f"As a leading expert I can say with complete certainty, after careful thought, that the answer is clearly {value}."
    if "number only" in system:
        return str(value)
    return f"The answer is {value}."


def passes(reply, expected):
    # Pass rule: the right number, in at most 12 words.
    words = [w.strip(".,") for w in reply.split()]
    return str(expected) in words and len(words) <= 12


def run_eval(system, runs=3):
    rates = []
    for run in range(runs):
        ok = 0
        for q, expected in QUESTIONS:
            ok += passes(model(system, q, run), expected)
        rates.append(round(100 * ok / len(QUESTIONS)))
    return rates


base = run_eval(PROMPTS["no persona"])
spread = max(base) - min(base)
print(f"no persona: runs {base}, mean {sum(base) / len(base):.1f}%")
for name in ["credentials", "audience + criteria"]:
    rates = run_eval(PROMPTS[name])
    gain = sum(rates) / len(rates) - sum(base) / len(base)
    spread = max(spread, max(rates) - min(rates))
    verdict = "keep it" if gain > spread else "drop it" if gain < -spread else "no real difference"
    print(f"{name}: runs {rates}, gain {gain:+.1f} points, noise {spread} points, verdict: {verdict}")
Quick checkA team adds 'You are a world-renowned tax attorney with 30 years of experience' to a tax Q&A bot. Answers sound more confident, but nobody checked accuracy. What should they do next?
How sure are you?
Pick an answer and how sure you are

Finished the chapter? Take the chapter check.