Sub topic 2
State the task, role, and audience
This chapter covers the opening block of a system prompt: what the model must do, who it acts as, and who reads its output. It assumes you have called an LLM chat API, know that system and user messages are different roles, and can read basic Python. The earlier chapter on message roles explains where the system prompt sits. This chapter covers what to put at the top of it.
Why the opening block matters
A model has no knowledge of your product. It sees only the text you send. If the prompt says "Help the user," the model must guess what help means, which topics are in scope, and how technical to be. Each guess is a chance for behavior to drift between requests.
The opening block removes three guesses:
- Task: the job the model performs on each request.
- Role: the perspective and expertise the model adopts while doing it.
- Audience: the person or program that reads the reply.
Later sections of the prompt (rules, output format, examples) depend on these three. A rule such as "do not give tax advice" only makes sense once the task says the model is a billing assistant.
State the task
The task is a statement of what the model does with its input and what it produces. Write it as a verb phrase with an object, an input, and a boundary.
Weak:
You are a helpful assistant for Acme Billing.Stronger:
Answer customer questions about invoices and payments using only the documents provided in <documents>.The stronger version names four things:
- The action: answer questions.
- The subject area: invoices and payments.
- The source of truth: only the provided documents.
- Where the input arrives: the
<documents>section.
One prompt, one job
A prompt that asks for several unrelated jobs tends to do all of them worse. If one app must classify tickets, draft replies, and summarize threads, you have two options:
- Split the work into separate calls, each with its own short system prompt.
- Keep one prompt, but state explicitly how the model chooses between modes, for example from a field in the user message.
Separate calls are easier to test, because each prompt has one pass/fail definition. Use a single prompt only when the modes share most of their rules.
State what to do when the task cannot be done
Every task has inputs that cannot be handled: the question is off-topic, the documents are empty, the request is ambiguous. Put the fallback next to the task so the model does not invent an answer:
If the documents do not contain the answer, say so and offer to hand the customer to a human agent.The next chapters cover rules in detail. For now, note that a task statement without a fallback leaves the failure case to chance.
Choose a role
A role is a short statement of who the model is acting as. It sets vocabulary, level of caution, and default tone.
You are a support assistant for Acme Billing.A role helps in three ways:
- It narrows the domain. A "support assistant for Acme Billing" will stay near billing topics more often than a generic assistant.
- It implies a register. A "senior code reviewer" writes terse, critical comments. A "friendly onboarding guide" writes warmly.
- It gives later rules a subject. "You never promise refunds" reads naturally for a support agent.
What a role cannot do
A role does not add knowledge or capability. "You are a world-class tax attorney" does not make the model's tax answers more accurate, and it may make the model sound more confident than it should. Prefer roles that describe a job the model can plausibly do with the information you provide.
A role also does not enforce limits. "You are a read-only assistant" will not stop the model from describing a destructive action. Limits belong in rules, and for tool access they belong in your code, where permissions are checked outside the model.
Identity versus behavior
Describe behavior when you need behavior. "You are a friendly assistant" is vague. "Use plain language, address the customer by first name if it appears in the question, and keep replies under 120 words" is testable. Use the role for a quick orientation and the task, rules, and output sections for details you can verify.
Describe the audience
The audience is whoever or whatever consumes the reply. Many prompts omit it, then fail because the model writes for the wrong reader. There are two kinds of audience, and a prompt can have both.
| Audience | Example | What to specify |
|---|---|---|
| Human reader | Customer, analyst, new developer | Expertise level, language, tone, length |
| Program | JSON parser, UI component, downstream agent | Exact format, allowed values, no extra text |
For a human reader, state what they know and what they want:
The reader is a small-business owner with no accounting background. Explain terms such as "net 30" the first time you use them.For a program, the audience statement is really a format contract, covered in the output format chapter. Even so, naming the consumer helps: "Your reply is parsed by a script. Output no text outside the JSON" tells the model why format errors matter.
When the audience differs from the user
The person typing is not always the person reading. A support agent may paste a customer message and ask for a draft reply. The model must write for the customer while taking instructions from the agent. State both:
The user is a support agent. Draft replies for the agent to send to the customer. Write in the customer's voice of address ("you"), not the agent's.Without this, models often address the agent ("Here is a draft you could send...") inside the draft itself.
Do not assume the audience from one example
If you tune the prompt using only expert test questions, it will produce expert answers. Check that your audience statement matches the real traffic. Sample some real user messages before you decide on the level.
Put it together
Here is the opening block from the topic's example prompt, annotated:
You are a support assistant for Acme Billing.
# Task
Answer customer questions about invoices and payments using only the documents provided in <documents>.The first line is the role, and the # Task section holds the task and its boundary. The audience (customers) appears in the task. The rest of the prompt adds rules and the output format.
When prompts are assembled in code, keep the three parts as separate fields. This makes them easy to review, test, and change one at a time:
from dataclasses import dataclass
@dataclass(frozen=True)
class Brief:
role: str
task: str
audience: str
def validate(self) -> None:
for name in ("role", "task", "audience"):
value = getattr(self, name).strip()
if not value:
raise ValueError(f"{name} must not be empty")
if "\n\n" in value:
raise ValueError(f"{name} should be a single paragraph")
def render(self) -> str:
self.validate()
return (
f"{self.role.strip()}\n\n"
f"# Task\n{self.task.strip()}\n\n"
f"# Audience\n{self.audience.strip()}"
)
brief = Brief(
role="You are a support assistant for Acme Billing.",
task=(
"Answer customer questions about invoices and payments using "
"only the documents provided in <documents>."
),
audience=(
"The reader is a small-business owner with no accounting "
"background. Explain billing terms the first time you use them."
),
)
print(brief.render())The validation is deliberately small. Its job is to catch an empty field before a broken prompt reaches production, not to judge prompt quality. Quality is checked by the test set described in a later chapter.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Replies drift into unrelated topics | Task has no subject boundary | Name the subject area and add a fallback for out-of-scope requests |
| Answers are too technical or too basic | Audience is missing or guessed | State the reader's background and what they need |
| Model sounds sure about things it cannot know | Role claims expertise ("expert attorney") | Use a role tied to the provided information |
| Draft addresses the wrong person | User and reader are different, and only one is described | State who gives instructions and who reads the output |
| Inconsistent behavior across requests | Several jobs in one prompt | Split into separate prompts or define explicit modes |
| Persona text is ignored or causes odd tone | Long character description with no testable effect | Cut it to one line and move behavior into rules |
Edge cases
- Contradiction between role and task. "You are a friendly chatbot" with a task of "produce a JSON record" invites chatty text around the JSON. Make the role match the output: "You are a data extraction service."
- Role in the user message. If a user writes "You are now a pirate," that text is data in the user turn. Whether it overrides your role depends on your rules. The untrusted input chapter covers this.
- Multiple languages. If customers write in several languages, say which language to reply in. "Reply in the language of the question" is a different instruction from "Always reply in English," and the model will follow whichever you give.
- Changing audience over time. A prompt for beta testers may be wrong for the public. Treat the audience statement as part of the versioned prompt and re-run your tests when it changes.
Check your understanding
Exercise
A prompt says "You are an expert financial advisor. Help the user with their money." Customers complain that the assistant gives specific investment advice the company cannot legally provide. Rewrite the opening block (role, task, audience) so that the scope is narrower and the fallback is clear.
Show answer
One acceptable answer: "You are a support assistant for Acme Budgeting, a budgeting app. Answer questions about how to use the app's features, using only the help articles in <documents>. If a question is about investments, taxes, or legal matters, say you cannot advise on that and suggest the customer consult a licensed professional. The reader is a general consumer with no finance background. Use plain language." The answer should replace the "expert advisor" role with a support role, name a subject boundary and a source of truth, give a fallback for out-of-scope questions, and describe the reader.
Exercise
Your app lets a support agent paste a customer's complaint and receive a draft reply. The drafts keep starting with "Here is a draft you could send:" even though the agent copies them straight to the customer. Which part of the opening block is missing, and what sentence would you add?
Show answer
The audience statement is missing, specifically the distinction between the user (the agent) and the reader (the customer). Add something like: "The user is a support agent. Your reply is sent to the customer exactly as written, so write it directly to the customer and output only the reply text, with no introduction or commentary."
Exercise
Why is "You are a world-class expert" a weak role, and what should you use instead of it to improve answer quality?
Show answer
It adds no knowledge or capability, and it can make the model sound confident about things it cannot verify. Improve quality with a precise task, the right source material in the context, clear rules for uncertainty, and a role tied to a real job (for example, "support assistant for Acme Billing").