Retrieval-augmented generation (RAG) is a technique in which a system first retrieves documents relevant to a request and then gives them to a language model as context for its answer.
How RAG works
The term comes from a 2020 research paper by Lewis and colleagues. A basic pipeline:
- Index: split your documents into chunks and store them, often as vector embeddings in a search index.
- Retrieve: for each request, find the most relevant chunks by semantic or keyword search.
- Augment: add those chunks to the model's prompt.
- Generate: the model answers using the supplied text, ideally citing it.
RAG lets a model use private or recent information without retraining, and it makes answers checkable against sources.
Limits
- Poor retrieval gives the model the wrong context.
- The model can still ignore or misread sources.
- Retrieved text is untrusted input and can carry prompt injection.
An example
An agent drafting a launch post searches your docs for the new feature, retrieves its help page, and writes the post from that page. The result names the correct plan limits instead of guessing.
Why it matters for AI-agent publishing
The biggest risk in agent-drafted posts is a confident, wrong claim. Grounding drafts in your own sources reduces that risk, and keeping the source lets a reviewer check.
With SocialHandoff, agents read your voice rules, products, and banned topics with get_brand_memory, a simple form of retrieval. The audit log stores citations such as the GitHub release a draft came from, so reviewers can see what it was built on.