What you will be able to do
- Write a prompt that limits Claude to the supplied documents and makes it return an exact 'not found' reply when they lack the answer
- Use document blocks with citations enabled so every claim comes back with a source location you can check
- Return retrieved passages as search_result blocks so answers carry source attributions without a custom citation parser
- Choose between sending the full document set and retrieving only relevant passages, based on corpus size, cost and freshness
Key concept
Grounded answer — An answer built only from the documents in the request. Each claim can be traced to a passage in those documents, and when the documents don't contain the answer, the reply says so instead of filling the gap from general knowledge.
1.Restricting answers to the documents and returning not found
A grounded assistant has two jobs, and most failures come from the second one. The first job is answering from the documents. The second is noticing when the documents say nothing and stopping there. Take an HR assistant built on a benefits handbook. Asked about relocation bonuses, which the handbook never mentions, it will often describe a typical industry policy. To the employee that reads like company policy, and it is wrong.
The fix is two explicit instructions working together. External knowledge restriction tells Claude to use only the supplied documents and not its general knowledge. Permission to say "I don't know" gives Claude an approved way out when the documents fall short, and this alone can sharply reduce false information. Put them together and the prompt looks like this: answer only from the handbook, and if it lacks the answer, reply exactly "Not found in the handbook" instead of guessing.
An exact not-found string matters for two reasons. It tells Claude precisely what to say when the documents fall short. It also gives your application a fixed value it can detect, so it can route the question to a human or log the gap in the handbook. The anti-hallucination guidance uses the same pattern for quote extraction: if Claude can't find relevant quotes, it is told to state "No relevant quotes found."
Common alternative instructions fail in predictable ways. "Prefer the handbook, otherwise use general knowledge with a disclaimer" still produces content the handbook never stated, and a disclaimer doesn't make it true for this company. A persona told to always give a confident answer pushes Claude toward guessing, which is the opposite of permission to admit uncertainty. A length limit controls how much Claude writes, not where its information comes from, so a three-sentence answer can be entirely invented.
Checkpoint 1 of 9· Check yourself
An HR assistant answers employee questions from a benefits handbook. Asked about relocation bonuses, which the handbook never mentions, it describes a typical industry policy, and employees take that as company policy. Which instruction fixes this?
Only this instruction does both jobs. It limits Claude to the handbook, and it gives Claude a fixed reply for when the handbook has no answer, which the app can also detect. A disclaimer still lets invented content through. A confident persona pushes Claude to guess. A length limit doesn't change where the information comes from.
“External knowledge restriction: Explicitly instruct Claude to only use information from provided documents and not its general knowledge.”Source: platform.claude.com
Checkpoint 2 of 9· Exam question
An HR assistant answers from an uploaded benefits handbook. When employees ask about topics the handbook omits, such as relocation bonuses, Claude fills in typical industry policy. Which instruction best fixes this?
Correct answer: C — Answer only from the handbook; if it lacks the answer, reply exactly "Not found in the handbook" instead of guessing
- A. Incorrect: allowing general knowledge as a fallback is the exact behaviour that creates invented policy. A disclaimer does not make the unsupported content grounded.
- B. Incorrect: a confident expert persona pushes Claude toward always answering. It removes the permission to say the information is missing.
- C. Correct: it restricts the source to the handbook and gives Claude explicit permission and a fixed phrase for the not-found case. That makes abstention easy to produce and easy for code to detect.
- D. Incorrect: shorter answers do not stop Claude from inventing a policy; a three-sentence fabrication is still a fabrication. Length is unrelated to whether the content is supported.
Sources1
2.Extracting quotes before answering
For long documents, ask Claude to pull word-for-word quotes out of the material before it answers. The guidance applies this to inputs above about 20k tokens. Extracting quotes first focuses Claude on the relevant passages and ignores the rest. The answer is then built from text that actually appears in the documents, not from a general impression of them.
A two-step prompt makes this concrete. In a compliance review of a privacy policy, step 1 tells Claude to extract the exact quotes relevant to GDPR and CCPA, and to state "No relevant quotes found" if there are none. Step 2 tells Claude to analyse only those quotes and refer to them by number. The not-found rule sits right at the extraction step, so an empty result stops the analysis before it can drift into general knowledge. Wrapping each document in tags with a source label, and putting the documents above the question, are layout techniques covered in prompt revision.
Prompt-level verification adds a check after the draft. Once Claude has written the response, have it find a supporting quote for each claim and retract any claim it can't support. In one press-release example, each removed claim is marked with empty [] brackets so a reviewer can see where something was cut. All of this is still text Claude writes, though. The next section covers the API feature that returns source locations as data.
Checkpoint 3 of 9· Check yourself
A team asks Claude to assess a 60k-token vendor contract for data-retention obligations. The analysis often cites retention rules that appear in no clause of the contract. Which prompt change best grounds the analysis in the contract?
Pulling exact quotes before analysis ties the answer to text that is actually in the contract, and putting the not-found rule at the extraction step stops the analysis when there is nothing relevant. A summary is a general impression of the text, listing sources after the fact doesn't limit what was claimed, and a confident persona pushes Claude to guess.
“ask Claude to extract word-for-word quotes first before performing its task. This grounds its responses in the actual text, reducing hallucinations.”Source: platform.claude.com
3.Document blocks with the Citations feature
Asking Claude in the prompt to tag each claim with "[Doc 3, p. 12]" produces tags that look reliable but aren't checked. The tag is generated text like everything else, so it can point to a page that doesn't contain the claim. Few-shot examples of well-formed tags make the tags more consistent, but they don't connect a tag to a location. Temperature 0 makes wrong tags repeatable. A second call that sees only the finished answer has no documents to check the pages against. And a self-reported confidence score is just more generated text.
The reliable fix is the Citations feature. Pass each file as a document content block and set citations.enabled to true. Claude's response then comes back as several text blocks, and each claim's block carries a list of citations pointing to specific locations in your documents. The API takes those locations from the documents themselves, so you can use them directly as your source tags. All active models support citations.
{
"type": "document",
"source": {
"type": "text",
"media_type": "text/plain",
"data": "Plain text content..."
},
"title": "Document Title",
"context": "Context about the document that will not be cited from",
"citations": { "enabled": true }
}The document type sets how fine-grained a citation can be and what the location looks like. Every citation also has a document_index, counted from 0 across all document blocks in the request, and a cited_text field holding the exact passage. cited_text doesn't count toward output tokens.
| Document type | Chunking | Citation location |
|---|---|---|
| Plain text | Sentence | Character indices (0-indexed, exclusive end) |
| Sentence, from extracted text | Page numbers (1-indexed, exclusive end) | |
| Custom content | None: your content blocks are used as-is | Block indices (0-indexed, exclusive end) |
Several constraints catch people out. Citations must be enabled on all of the documents in a request or none of them. Only text can be cited, so a scanned PDF with no extractable text gives Claude nothing to cite. For field extraction, prompt for one field: value line per field, reassemble the lines from the text blocks, and then check that every field has both a value and at least one citation, because the API guarantees neither. Parsing that output defensively is covered in structured output.
Checkpoint 4 of 9· Fill the gap
This document block should return citations that point to locations in the text. Which field name completes it?
{
"type": "document",
"source": {
"type": "text",
"media_type": "text/plain",
"data": "Plain text content..."
},
"title": "Document Title",
"context": "Context about the document that will not be cited from",
" ? ": { "enabled": true }
}Setting citations.enabled to true on a document block turns on the Citations feature. The API then returns locations taken from the document, not source tags that Claude writes as ordinary text. The other names are not fields of a document block.
Source: platform.claude.comCheckpoint 5 of 9· Check yourself
Your extraction pipeline sends four policy documents with citations enabled and asks for one 'field: value' line per field. After it rebuilds the lines from the text blocks, what should the code do before saving the results?
The API guarantees neither a value nor a citation for each field, so the code has to check both after parsing. A JSON-only prompt can leave you with few or no citations. Few-shot tags are generated text and are not tied to real locations in the documents.
“Check that each field has a value and at least one citation. The API doesn’t guarantee either.”Source: platform.claude.com
Checkpoint 6 of 9· Exam question
A developer asks Claude in the prompt to end each claim with a source tag like "[Doc 3, p. 12]". Reviewers find tags that point to pages which do not contain the claim. What is the most reliable fix with the Messages API?
Correct answer: D — Pass each file as a document content block with citations enabled, and use the returned citation locations as the tags
- A. Incorrect: a second call that sees only the finished answer has no access to the source pages, so it can only judge whether a page number looks plausible. That is still a guess, and wrong tags will pass or be replaced with other wrong ones.
- B. Incorrect: few-shot examples and a low temperature make the tag format more consistent, but Claude still writes the document and page numbers from memory. Nothing links a tag to the passage it should point to, so mismatched pages remain possible.
- C. Incorrect: a confidence score written by the model is not calibrated evidence that a page supports a claim. A wrong tag can carry a high score and skip review, so the unreliable tags are not reliably caught.
- D. Correct: with citations enabled on document blocks, the API returns citation locations tied to the supplied text rather than numbers composed by the model. Using those returned locations as the tags removes the self-reported pointers that were wrong.
Sources3
4.Search result blocks for your own retrieval
With your own vector search, retrieved passages don't arrive as files, but they can still be cited automatically. Return each passage from your search tool as a search_result content block with a source and a title. Claude then cites your content the same way it cites web search results, and each citation carries the source and title you supplied. No special prompting is needed, and you don't need a parser that maps sentences back to URLs.
{
"type": "search_result",
"source": "https://docs.company.com/guide",
"title": "User Guide",
"content": [{ "type": "text", "text": "Important documentation..." }],
"citations": {
"enabled": true // Enable citations for this result
}
}The block format comes with rules. The content array holds only text blocks, so images and other media aren't allowed. search_result blocks can appear only in user messages, which includes inside tool results. Inside a tool_result, it's all or nothing: if any block is a search_result, every block must be one. To add supporting text, put it as a text block inside a search result's content, where it also becomes citable. Splitting long content into logical text blocks gives Claude finer citation boundaries. Each citation comes back as a search_result_location with the source, the title, a search_result_index and block indices.
The retrieval path needs its own not-found behaviour. When a search fails or returns nothing, return a plain text block such as "No results found." instead of raising an error. Claude explains the empty result to the user and the conversation continues. Combined with the instruction to answer only from retrieved content, this gives the same honest 'not found' as the prompt-level rule earlier.
Checkpoint 7 of 9· Fill the gap
Your vector-search tool hands back a passage from your own docs site. You want Claude to cite it and show the source and title you supplied. Which block type completes this tool output?
{
"type": " ? ",
"source": "https://docs.company.com/guide",
"title": "User Guide",
"content": [{ "type": "text", "text": "Important documentation..." }],
"citations": {
"enabled": true // Enable citations for this result
}
}A search_result block with a string source, a title, a content array of text blocks and citations enabled lets Claude cite your retrieved passages the way it cites web search results, with your source and title on each citation. A document block takes a source object, not a URL string. A tool_result is the wrapper that holds these blocks, not the passage itself.
Source: platform.claude.comCheckpoint 8 of 9· Exam question
A team runs its own vector search and returns passages from a search tool. They want Claude's final answer to carry clickable source attributions per claim without the team writing a citation parser. What should the tool result contain?
Correct answer: C — Search result content blocks holding each passage's source and title, with citations enabled so claims link back to them
- A. Incorrect: a concatenated text block loses passage boundaries, so Claude can only write URLs freehand and the team is back to unverified tags.
- B. Incorrect: image blocks are for visual input, and encoding text that way does not produce citable passages.
- C. Correct: search result blocks are built for retrieval pipelines and carry source and title with each passage. With citations on, Claude attributes claims to specific results natively.
- D. Incorrect: IDs without the content give Claude nothing to ground on, so it cannot quote or cite real text in its answer.
Sources4
5.Full document set or retrieved passages: size, cost and freshness
Once you know how to ground and cite, the remaining decision is what goes into the request: the whole corpus as document blocks, or only the passages retrieved for this question. Three factors decide it: corpus size, cost and freshness.
Corpus size sets the hard limit and the soft one. Current models such as Claude Opus 5.5, Sonnet 5.5 and Haiku 5.5 have a 1M-token context window. Other models, including Claude Sonnet 4.5, have 200k. Everything in the request counts toward the window: system prompt, documents, tool definitions and the output. A request can also include at most 600 images or PDF pages, or 100 on 200k models, so a large set of PDFs can hit the request size limit before the token limit. Fitting isn't the whole story either. As token count grows, accuracy and recall degrade, which is called context rot (see context management). That argues for retrieval even when the full set technically fits.
Cost grows with every token you send, on every request. On Claude Haiku 5.5, prompts over 100,000 tokens cost more than standard pricing. Prompt caching changes the calculation for a large, stable document set: put cache_control on the document blocks, and later requests with the same prefix reuse them, with less processing time and cost. Citations and caching work together, because the source documents can be cached even though the citation blocks can't. The catch is lifetime. Caches use a 5-minute or 1-hour TTL, so a 400k-token archive queried about once an hour with a 5-minute cache is re-sent at full cost every time. Either the TTL has to cover the gap between questions, or retrieval has to shrink what gets sent. Enabling citations itself adds only a little input cost. The economics of caching are covered in cost optimization.
Freshness favours retrieval when content changes. A document set placed in the prompt and cached is the version you sent. A search tool fetches content at runtime, and Claude cites what it returned. To make sure retrieval runs on every turn, force the tool call with tool_choice. Return only the most relevant results so the context doesn't overflow.
Checkpoint 9 of 9· Match them up
When deciding whether to send the whole corpus or only retrieved passages, several mechanisms affect the choice. Match each one to its effect on that decision.
Tap a term, then the definition that fits it.
Size has two limits: the hard window and page caps, and the softer loss of accuracy known as context rot. Caching cuts the cost of a stable full set only while the TTL covers the time between queries. Forced retrieval handles freshness because it fetches content at runtime.
“As token count grows, accuracy and recall degrade, a phenomenon known as context rot.”Source: platform.claude.com
Sources
(6)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.https://platform.claude.com/docs/en/test-and-evaluate/strengthen-guardrails/reduce-hallucinationsOfficial docs
“External knowledge restriction: Explicitly instruct Claude to only use information from provided documents and not its general knowledge.”
↩︎ Restricting answers to the documents and returning not found“Explicitly give Claude permission to admit uncertainty. This technique can drastically reduce false information.”
↩︎ Restricting answers to the documents and returning not found“If you can't find relevant quotes, state "No relevant quotes found."”
↩︎ Restricting answers to the documents and returning not found“Only base your analysis on the extracted quotes.”
↩︎ Extracting quotes before answering“If it can’t find a quote, it must retract the claim.”
↩︎ Extracting quotes before answering“External knowledge restriction: Explicitly instruct Claude to only use information from provided documents and not its general knowledge.”
↩︎ Exam trap 1“ask Claude to extract word-for-word quotes first before performing its task. This grounds its responses in the actual text, reducing hallucinations.”
↩︎ Checkpoint - 2.https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practicesOfficial docs
“ask Claude to quote relevant parts of the documents first before carrying out its task.”
↩︎ Extracting quotes before answering - 3.
“Set citations.enabled=true on each of your documents. Currently, citations must be enabled on all or none of the documents within a request.”
↩︎ Document blocks with the Citations feature“For PDFs: Citations include the page number range (1-indexed).”
↩︎ Document blocks with the Citations feature“The cited_text field is provided for convenience and does not count toward output tokens.”
↩︎ Document blocks with the Citations feature“PDFs that are scans of documents and do not contain extractable text are not citable.”
↩︎ Document blocks with the Citations feature“The citation blocks generated in responses cannot be cached directly, but the source documents they reference can be cached.”
↩︎ Full document set or retrieved passages: size, cost and freshness“Citations return the exact passages that support each claim, so you can verify answers and surface sources to your users.”
↩︎ Key concept“Check that each field has a value and at least one citation. The API doesn’t guarantee either.”
↩︎ Exam trap 2“Currently, citations must be enabled on all or none of the documents within a request.”
↩︎ Exam trap 3“A request with such a prompt succeeds, but the response might contain few or no citations.”
↩︎ Prediction“Check that each field has a value and at least one citation. The API doesn’t guarantee either.”
↩︎ Checkpoint - 4.
“each citation carries the source and title you provided.”
↩︎ Search result blocks for your own retrieval“No special prompting is needed: ask your question, and citations appear on the text blocks that draw on your content.”
↩︎ Search result blocks for your own retrieval“search_result blocks can only appear in user messages (including inside tool results).”
↩︎ Search result blocks for your own retrieval“Claude explains the empty result to the user, and the conversation continues.”
↩︎ Search result blocks for your own retrieval“tools fetch content at runtime, and Claude cites it in the response.”
↩︎ Full document set or retrieved passages: size, cost and freshness“Result limits: Return only the most relevant results to avoid context overflow”
↩︎ Full document set or retrieved passages: size, cost and freshness“if any block in a tool_result content array is a search_result, all of its blocks must be search_result.”
↩︎ Exam trap 4“Citations are disabled by default; every example on this page sets "enabled": true explicitly.”
↩︎ Prediction - 5.
“As token count grows, accuracy and recall degrade, a phenomenon known as context rot.”
↩︎ Full document set or retrieved passages: size, cost and freshness“If you send many images or large documents, you might reach request size limits before the token limit.”
↩︎ Full document set or retrieved passages: size, cost and freshness“long-context requests are billed at standard pricing, except on Claude Haiku 5.5, where prompts over 100,000 tokens cost more.”
↩︎ Full document set or retrieved passages: size, cost and freshness - 6.
“using automatic caching or explicit breakpoints with 5-minute or 1-hour TTLs.”
↩︎ Full document set or retrieved passages: size, cost and freshness