Sub topic 14
Writing instructions that keep answers grounded
This chapter assumes you can build a retriever over Knowledge content and attach it to a prompt template or an agent's knowledge action. Here you write the instructions that decide whether the model stays inside the retrieved content.
Why instructions matter
A retriever supplies excerpts. It does not stop the model from answering from its general training. If the instructions are vague, the model may blend excerpts with outside facts, or answer confidently when retrieval returned nothing. Instructions are the control that closes that gap.
Grounding instructions appear in two places:
- Prompt template text: the prompt you build in Prompt Builder, where retriever results are inserted.
- Agent topic instructions: the rules that tell an agent when to call its knowledge action and how to use the result.
Four rules every grounding instruction needs
- Restrict the source. Say the answer must come only from the provided excerpts.
- Define the empty case. State what to do when no relevant excerpt is returned.
- Forbid outside knowledge. Say so explicitly, not just by implication.
- Require attribution. Ask the model to name the article title it relied on, so reviewers can check the answer.
A prompt template example
This text follows all four rules. The bracketed lines stand for the retriever and input resources you add in Prompt Builder.
Answer the customer's question using only the knowledge article excerpts provided below.
If the excerpts do not contain the answer, say you could not find it and offer to connect the customer with a human agent.
Do not use outside knowledge. Mention the article title when you rely on an excerpt.
Excerpts:
<retriever results inserted here by the prompt template>
Question:
<customer question inserted here>Rule 1 is the first sentence. Rule 2 is the second sentence. Rules 3 and 4 are in the third.
An agent topic example
An agent needs a different kind of instruction. It must decide to call the action before it answers.
When a customer asks a product or policy question, use the knowledge action to look up the answer.
Base your reply only on the returned articles.
If no relevant article is returned, do not guess. Tell the customer you do not have that information and offer escalation.The first line links the question type to the action. The last two lines cover the source restriction and the empty case.
Common mistakes
| Mistake | Effect | Fix |
|---|---|---|
| No fallback defined | The model guesses when retrieval is empty | Add an explicit "if not found" step |
| "Try to use the articles" | Outside knowledge leaks in | Use "only" and "do not" wording |
| Topic never mentions the knowledge action | The agent answers without retrieving | Name the action and the trigger |
| Instructions contradict each other | Inconsistent answers | Keep one rule per behavior |
Keep instructions short and testable
Write each rule so you can check it with a test question. "Offer escalation when nothing is found" is testable: ask something your articles do not cover and see whether the agent escalates. "Be accurate" is not testable. Short, concrete rules are also easier to debug when an answer goes wrong.
Exercise
An agent's topic says "Answer product questions helpfully, using the knowledge articles when possible." Which two grounding rules does it fail to apply, and how would you rewrite it?
Show answer
It fails to restrict the source ("when possible" allows outside knowledge) and to define the empty case (no fallback). Rewrite: "Use the knowledge action for product questions. Base your reply only on the returned articles. If no relevant article is returned, do not guess. Say you do not have that information and offer escalation."