Skip to content
Rota Nacional

Guides ·

How to send only the necessary passage in a RAG workflow

Enforce access before retrieval and process retrieved passages before adding them to prompts.

1. Enforce access during retrieval. Searches must respect user, organization and document permissions before returning results. Do not retrieve an entire database and expect the model to ignore unauthorized material. Preserve each passage's reference for answer verification.

2. Limit context by relevance. Set passage count and size limits, remove duplicates and keep only material supporting the task. Prefer one sufficient passage over complete documents. Allow answers to acknowledge missing evidence when retrieval finds nothing useful.

3. Process every passage before inference. Documents may contain names, contacts and identifiers unrelated to the question. Apply the policy to retrieved context and messages. Instructions inside documents are source content, not permission for tools.

4. Verify isolation and fidelity. Run the same search for two fictional projects and confirm results reflect their access rights. Check that answers rely on permitted passages, acknowledge gaps and avoid removed details. Revisit retrieval as the document collection changes.

Get new articles

Privacy, AI engineering and security in your inbox.

Rota Nacional

Bring privacy into your workflow.

30 days, no card, with a starting quota. After that, Pix credit from R$ 5,00.

Try free