Writing System Prompts for Agents
Write agent instructions that define role, tools, limits and done, and hold up across thousands of runs
A taste of a lesson
My prompt says 'NEVER give medical advice' in capitals, and now the agent refuses to tell users our clinic's opening hours. Why?
The rule is strong and has no boundary, so the model is playing it safe with anything clinic related. Replace it with a rule that has a reason and a scope: 'Do not diagnose or recommend treatment, because only clinicians can do that safely. You can share practical information such as opening hours, locations, booking steps and preparation instructions from the clinic's pages.' Then add one example of each. Rerun your test cases for both refusals and over refusals. Which other questions has it been refusing lately?
Written by the teacher as an example. In your lesson the tutor answers your own questions, and like any AI it can be wrong.
What you will be able to do
- Structure agent instructions around role, context, tool strategy, rules, escalation and done
- Write rules with reasons so the agent generalises to new situations
- Remove contradictions and duplication between prompts and tool descriptions
- Use varied examples for edge cases without causing copycat behaviour
- Test, version and roll out prompt changes against an evaluation set
Lesson plan
- 1 Agent prompts versus chat prompts Understand what extra jobs an agent's system prompt has to do. Start
- 2 A structure that scales Organise instructions into clear sections that are easy to maintain. Start
- 3 Rules with reasons Write rules that the agent can apply sensibly to situations you did not foresee. Start
- 4 Uncertainty, escalation and done Tell the agent what to do when it is unsure and how to know it has finished. Start
- 5 Examples for edge cases Use short examples to shape tricky behaviour without overfitting. Start
- 6 Testing and versioning prompts Change prompts safely with evidence and traceability. Start
Try asking
About this tutor
For developers and prompt designers whose agent instructions have grown into a long, contradictory wall of text. A system prompt for an agent is different from a chat prompt: it must guide tool choice, decisions under uncertainty, stopping and escalation, across many varied runs. You will learn a clear structure for agent instructions, how to write rules with reasons, how to describe tool use strategy without duplicating tool descriptions, how to handle edge cases with examples, and how to test and version prompt changes. We rewrite real looking prompts together.
Reviews
4.5
2 ratingsSample
- Sana Q.Sample
Very good editing eye. I would have liked more examples from different domains, but the structure is something I use daily now.
- Bruno A.Sample
We cut our prompt from about 2,500 words to under 900 and the agent behaves better. The 'rules with reasons' lesson did most of the work.
About the teacher
I help teams turn agent ideas into useful assistants for support, research and data work
9 tutors 315 lessons taught Sample
I work on the practical end of agents: the support assistant that answers customers, the research helper that reads and cites, the analyst that queries a database and explains what it found. I spent a long time in customer facing technical roles, so I care about what the person on the other side experiences, not only about what the model...
See Jamal's profile and tutorsMore like this
Other tutors on the same or nearby topics.