Three message roles
| Role | Who writes it | What goes in it |
|---|---|---|
| system | The developer | Persona, scope, rules, tone, output format, what to do when unsure. Newer APIs also accept a developer role, and the Responses API takes the same content as instructions. |
| user | The end user | The current question or instruction |
| assistant | The model | Previous replies, replayed to give the model conversation history |
(none)
My order #4471 has not arrived. What do I do?
I'm sorry to hear that! Order delays can happen for lots of reasons - carrier backlogs, weather, an address issue, or the parcel being held at a depot. Have you checked your tracking link? Usually the carrier updates it within 24 hours. If it has been more than a week, most retailers will let you open a claim, and some will send a replacement while the investigation runs. You may also want to check with neighbours…
Rambling, no format, no boundaries, and it invents policy the company may not have.
Check your understanding
What belongs in the system message rather than the user message?
Prompting techniques
| Technique | What it is | Use it when |
|---|---|---|
| Zero-shot | State the task, give no examples | The task is common and the format is obvious |
| Few-shot | Include several input → output examples | You need an exact output format or labelling scheme |
| Chain-of-thought | Ask the model to reason step by step | Multi-step reasoning or logic problems |
Know this: None of these change the model
All three are inference-time techniques that cost prompt tokens and require no training. Fine-tuning is the one that changes weights. A question offering "fine-tune the model" as a fix for a formatting or tone problem is usually the wrong answer - try the system prompt first.
Check your understanding
A prompt includes three worked examples of input and the desired labelled output before the real input. What is this technique called?
Check your understanding
Which prompting technique most improves a model's performance on a multi-step arithmetic or logic problem?
What makes a system prompt good
- Role and scope - who the assistant is, and explicitly what it will not discuss.
- Output format - state it, and show an example of it.
- Failure behaviour - "if the answer is not in the provided context, say you do not know". This single line prevents a great deal of hallucination in grounded apps.
- Tone - one concrete sentence beats three adjectives.
You are a support assistant for Contoso Cloud.
Answer only from the context provided in the conversation.
If the answer is not in the context, say: "I don't have that information."
Never discuss competitors or pricing.
Reply in at most three sentences, plain language, no marketing tone.Check your understanding
A support assistant sometimes answers questions about competitors and occasionally replies in a chatty tone that does not match the brand.
What is the most appropriate first fix?
Check your understanding
Which two practices make a system prompt more effective? (Choose two.)
Choose 2. Each correct answer is part of the solution. Each correct selection is worth one point.
A lightweight chat client
You will not be asked to write this from scratch, but you should recognise the shape and know what each piece is for.
What every Foundry chat client does
Get a credential
Microsoft Entra ID (keyless) is the recommendation -
DefaultAzureCredentialfor development, a specific credential such as a managed identity in production. Keys work too, but never put them in source code.Point at the project endpoint
Typically
https://<your-resource>.services.ai.azure.com/api/projects/<project-name>, read from an environment variable such as PROJECT_ENDPOINT.Build the messages
A system message with your standing instructions, then the user message, plus any prior assistant messages for history.
Call the model by deployment name
Pass the deployment name you chose in the portal - or, with instant access, the model name - plus any parameters that model supports.
Read the reply
Take the generated content out of the response and show it to the user.
import os
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
# pip install "azure-ai-projects>=2.3.0" azure-identity
project = AIProjectClient(
endpoint=os.environ["PROJECT_ENDPOINT"],
credential=DefaultAzureCredential(),
)
openai = project.get_openai_client()
response = openai.responses.create(
model=os.environ["MODEL_DEPLOYMENT_NAME"],
instructions="You are a concise IT support assistant.",
input="What is an AI agent?",
)
print(response.output_text)You will also meet the older Chat Completions shape - client.chat.completions.create(messages=[...]), reading response.choices[0].message.content. It still works and the message roles are identical; Microsoft recommends the Responses API for new apps because it carries the newest features.
Changed: If your notes use a connection string
Older samples authenticate with AIProjectClient.from_connection_string(...), or use version 1.x of azure-ai-projects. Current samples use version 2.x with a project endpoint and a Microsoft Entra credential. Recognise both, prefer the current one.
Check your understanding
Which two values does a lightweight Foundry chat client typically need in order to call a deployed model?
Check your understanding