Prompts, few-shot examples and structured output
There are three ways to control what an agent says. You can tell it, show it, or give it a form to fill in.
| Technique | Analogy | Use it for |
|---|---|---|
| System prompt | A job description | Role, tone, rules and what to do when unsure |
| Few-shot examples | Showing a new hire a few finished tickets | A consistent format or style that's hard to describe |
| Structured output | A form with fixed boxes | Answers your code needs to read, as JSON |
The system prompt: tell it
The system prompt is a standing instruction the agent follows in every conversation. The user never sees it.
A good system prompt covers:
- Role. "You are the support assistant for Acme's billing team."
- Audience and tone. "Customers are not technical. Be short and friendly."
- Rules. "Never promise a refund. Point people to the refund form instead."
- What to do when unsure. "If the answer isn't in the documents, say so and offer to connect them with a human."
The last point matters most. Without it, a model may guess.
Zero-shot, one-shot and few-shot: show it
A shot is one example: a sample user message with the ideal answer.
| Approach | What you give the agent | Result |
|---|---|---|
| Zero-shot | Instructions only, no examples | Works for general tasks. The format can drift. |
| One-shot | One example | The agent copies its shape. It may copy it too closely. |
| Few-shot | Two to five varied examples | The agent picks up the pattern and applies it to new messages. |
Examples are powerful because models are excellent at continuing a pattern. It's often easier to show a format than to describe it.
Zero-shot. The prompt says "Classify the ticket." Replies vary, such as "This seems like a billing issue" or "Category: billing (high priority?)".
Few-shot. Add two examples:
| User | Assistant |
|---|---|
| My order has not arrived. | Category: Shipping. Priority: High. |
| I want to change my email. | Category: Account. Priority: Low. |
Now "I was charged twice" gets "Category: Billing. Priority: High." Same format, every time.
- Python
- TypeScript
Custodian(
model="gpt-6-luna",
system_prompt="You triage support tickets.",
examples=[
{"user": "My order has not arrived.", "assistant": "Category: Shipping. Priority: High."},
{"user": "I want to change my email.", "assistant": "Category: Account. Priority: Low."},
],
)
new Custodian({ model: "gpt-6-luna", systemPrompt: "You triage support tickets." }).addExamples([
{ user: "My order has not arrived.", assistant: "Category: Shipping. Priority: High." },
{ user: "I want to change my email.", assistant: "Category: Account. Priority: Low." },
]);
Writing good examples
- Vary them. Cover different kinds of message, such as a short one, a long one and an unusual one. Similar examples teach the agent less.
- Make every example perfect. The agent copies mistakes as faithfully as good answers.
- Keep it to a few. Two to five is usually enough. Each example adds to every request's size and cost.
- Show the hard cases. Include an example of what to do when the answer is unknown, or when a request is out of scope.
Structured output: give it a form
When software reads the answer, not a person, you want reliable JSON rather than sentences. A response schema is a description of the exact fields you want, written as JSON Schema.
{
"type": "object",
"properties": {
"category": { "type": "string" },
"priority": { "type": "string", "enum": ["low", "medium", "high"] }
},
"required": ["category", "priority"]
}
This says: return an object with a category text field and a priority field that
must be low, medium or high. The agent's reply then includes a parsed
structured_output, such as {"category": "Billing", "priority": "high"}, alongside
the normal text.
On a squad, a response_schema on the squad shapes the final answer, whatever the
individual agents return.
Which should I use?
| You want | Use |
|---|---|
| The agent to behave a certain way | System prompt |
| Answers in a consistent style or layout | System prompt plus few-shot examples |
| Data your code can read | Structured output |
They work well together. A common setup is a clear prompt, two or three examples and a schema.
See it in code: Few-shot and structured output template.