Reference sheet · lessons 4, 5, 7

Retrieval & Graph RAG

The compressed essence of the answer-engine lessons. Print it; pin it next to your editor.

The tiers, in order

TierAnswers whenReturnsGuard
0 · Human requestedVisitor asks for a personHandoff into tawk.toPhrase list; never argue
1 · FAQTop score ≥ threshold and gap to runner-up ≥ marginCanonical answer verbatim + source URLTest set: zero wrong first
2 · Approved sourcesRetrieval finds allowed chunks and the model cites themGrounded text + citationsisAllowedUrl() ×3, NOT_IN_SOURCES sentinel
3 · FallbackEverything elseHonest “not in my sources” + offer of a personhandoff: true

FAQ tier dials (lesson 4)

Citations request shape (lesson 5)

{ "type": "document",
  "source": { "type": "text", "media_type": "text/plain", "data": "chunk text" },
  "title": "Support channels",
  "context": "Source URL: https://help.harbor.example/support",   // read, never cited
  "citations": { "enabled": true } }

Domain filter rules (web search / web fetch)

RuleExample
No schemeexample.com, not https://example.com
Bare domain includes subdomainsexample.com covers docs.example.com
Named subdomain restricts to itselfdocs.example.com excludes example.com, api.example.com
Paths: web search onlyexample.com/blog matches /blog/post-1; a path entry never matches a web fetch
allowed XOR blockedBoth in one request → 400
Wildcards only in pathsexample.com/* ok; *.example.com rejected
ASCII onlyHomograph domains look identical and are not

Source: server tools docs.Claude docs: Server tools, domain filtering Web fetch extras: latest type web_fetch_20260318; params max_uses, allowed_domains, citations, max_content_tokens, use_cache; only URLs already in the conversation are fetchable (url_not_in_prior_context); no JavaScript rendering; no extra fee beyond tokens (≈2,500 tokens per 10 kB page).Claude docs: Web fetch tool Web search costs $10 per 1,000 searches and always cites.Claude docs: Web search tool

Prompt caching facts

Retrieval quality levers (when you move past the FAQ)

Graph RAG decision table (lesson 7)

Question shapeChunksGraph (local)Graph (global)
One fact on one pagebestequal, costlierwasteful
Two facts joined across pages (multi-hop)misses the bridge at small kbestn/a
Themes across the corpuscannotcannotbest, prone to answering null questions
Unanswerable questionrefuses wellok with sentinelhallucinates

Prototype API (examples/)

matchFaq(faq, question, { strategy: "tfidf", threshold: 0.5, margin: 0.1 })  // → { hit, entry|reason, ranked }
isAllowedUrl(url, ["harbor.example", "docs.partner.example/help"])               // → boolean
groundedAnswer(question, chunks)                                                 // → { text, citations, grounded }
answer(question, { faq, allowedSources, retrieve, generate })                    // → { tier, text, citations, handoff }
new GraphIndex(parseTriples(text)).neighborhood(seeds, 2)                        // → { nodes, triples }