Beginner level · Module 3: Prompt Engineering for AI Agents · Lesson 2 of 3
Grounding, Citations and Refusals
Learners write rules that keep answers inside approved documents, require citations and define when the agent must decline or hand over to a person.
In this lesson you will
- Write grounding and citation rules
- Write refusal and hand-over rules
Key concepts
groundingcitationrefusalhand-overout-of-scope questions
The lesson
Grounding means the agent answers from provided sources, not from general memory. A citation rule requires naming the document (and section) for each answer, which lets staff and users check it.
Refusal rules cover questions outside the documents, requests for personal information and requests for actions the agent cannot take. A good refusal is helpful: it explains briefly and points to the right person or office.
Hand-over rules say when a person must take over: complaints, anything involving money or records, or whenever the agent is uncertain.
Step by step
- Add grounding, citation, refusal and hand-over rules to the project instructions.
- Write ten test questions, including four that must be refused or handed over.
- Run them and record the results.
- Fix the rules for any failures.
Rewriting a college enquiry assistant's instructions
The same assistant with a vague instruction and with a structured, testable one.
Before
Vague: no sources, no limits, no hand-over.
- 'You are a helpful assistant for the college. Answer students' questions about fees and courses.'
- No statement of which information may be used
- No rule for questions it cannot answer
- No output format, so answers cannot be checked by a program
- Nothing about money, complaints or personal data
After
Structured: role, sources, rules, format and hand-over.
- Role and audience: 'You answer questions from applicants and parents about fees, admissions and timetables at a fictional college.'
- Sources: 'Use only the passages returned by the search_documents tool. Never use general knowledge for fees, dates or rules.'
- Rules: 'If the passages do not contain the answer, say so and give the admissions office contact. Never ask for or reveal personal information. Never promise payments, discounts or admission.'
- Hand-over: 'Set needs_human to true for complaints, payment problems or anything about an individual student's record.'
- Format: 'Return JSON with answer, source_ids (at least one), confidence (0 to 1) and needs_human.'
What changed and why
- Grounding and citation rules stop the assistant from inventing fees or dates.
- Refusal and hand-over rules keep money, complaints and personal records with people.
- A fixed JSON format lets the program check every answer before anyone sees it.
- Each rule can be tested with specific questions in the test set.
Practice activity
Produce version 2 of the project instructions with tested grounding and refusal rules.
Expected result: Instructions under which the agent cites sources and correctly declines or hands over the out-of-scope questions.
Check your understanding
-
What does grounding mean for an agent?
Show answer
Answering from provided sources rather than general model memory.
-
What makes a refusal helpful?
Show answer
It explains briefly and directs the user to the right person or office.
Further learning
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.