Sub topic 2
State the task, role, and audience
This chapter assumes you have called an LLM chat API, can read basic Python and JSON, and know that a system message holds instructions that persist across a conversation. Here you will write the opening section of a system prompt: what the model does, who it acts as, and who reads its output.
Why the opening matters
The model has no knowledge of your product. It sees only the text you send. If the prompt says "Help users with billing," the model must guess what help means, which documents to trust, and how technical to be. Each guess is a chance for behavior to drift between requests.
Three statements remove most of that guessing:
- Task: the specific job, with a clear boundary.
- Role: the part the model plays, which sets default tone and expertise.
- Audience: who reads the reply, which sets vocabulary and depth.
State the task
Write the task as a verb phrase plus its inputs and limits. Name where the information comes from.
Weak: "You help with invoices."
Stronger: "Answer customer questions about invoices and payments using only the documents provided in <documents>."
The stronger version says what to do (answer questions), about what (invoices and payments), and from which source (the provided documents). The phrase "using only" turns a vague job into a testable one: you can check whether an answer relied on outside knowledge.
Keep one primary task per prompt. If the app needs classification and drafting, consider two prompts, or state the order of steps explicitly.
Choose a role
A role is a short identity line, such as "You are a support assistant for Acme Billing." It helps the model pick a register and a scope. It is not magic. A line like "You are the world's best accountant" adds no knowledge and can push the model to sound confident about things it cannot verify.
Good roles are:
- Specific to the product: "support assistant for Acme Billing", not "helpful AI".
- Honest about capability: the role should match what the model can do with the context you give it.
- Short: one sentence. Put detail in the task and rules.
Name the audience
The audience is the reader of the output, which may be a person or a program. Say which.
| Audience | What to state | Effect on output |
|---|---|---|
| Customer with no accounting background | "Explain in plain language. Define any billing term." | Short sentences, few acronyms |
| Internal support agent | "Assume familiarity with our invoice states." | Terse, uses internal terms |
| Downstream code | "Your reply is parsed by a program." | Strict format, no chatty text |
When the reader is a program, the audience statement and the output format (covered in a later chapter) work together. When the reader is a person, the audience statement controls reading level and tone.
Put it together
You are a support assistant for Acme Billing.
# Task
Answer customer questions about invoices and payments using only the documents provided in <documents>.
# Audience
Your readers are customers with no accounting background. Use plain language and define any billing term you use.This is the first part of the full system prompt shown in the topic plan. Rules and output format come after it. Short headings such as # Task and # Audience make each part easy to find and edit later.
The Python below keeps the opening as a separate constant, so you can change the role or audience without touching the rules.
ROLE = "You are a support assistant for Acme Billing."
TASK = (
"# Task\n"
"Answer customer questions about invoices and payments "
"using only the documents provided in <documents>."
)
AUDIENCE = (
"# Audience\n"
"Your readers are customers with no accounting background. "
"Use plain language and define any billing term you use."
)
OPENING = "\n\n".join([ROLE, TASK, AUDIENCE])
if __name__ == "__main__":
print(OPENING)Common errors
- Role without a task. "You are a friendly expert" says who, not what to do.
- Task that mixes jobs. Answering, summarizing, and translating in one sentence leads to inconsistent replies.
- Missing source. If you do not say where facts come from, the model fills gaps from memory.
- Unstated audience. The same answer written for an expert confuses a beginner.
- Describing the user instead of the reader. The audience is who reads the output, which can differ from who typed the question.
Exercise
A prompt says "You are an expert assistant. Be helpful." The app summarizes legal contracts for non-lawyers. Rewrite it to state the task, role, and audience in three short lines.
Show answer
One valid answer: "You are a contract-summary assistant for Acme Legal. Task: summarize the contract text provided in <contract>, using only that text. Audience: readers with no legal training, so use plain language and explain any legal term." The role names the product, the task names the source and boundary, and the audience sets the reading level.
Exercise
Your app's replies are parsed by a script that expects JSON. Why should the audience section say so, and what could go wrong if it does not?
Show answer
Without it, the model may assume a human reader and add friendly text such as "Sure, here is your answer" around the JSON. The parser then fails. Stating that a program reads the reply tells the model to output only the required format.