Skip to main content
Retrieval-augmented generation (RAG) applications combine user queries with retrieved knowledge base content before sending to an LLM. This creates governance challenges on both sides — the input may contain PII or injection attempts, and the output may leak sensitive data from the knowledge base. This flow shows how TealTiger governs the full RAG pipeline.

Orchestration Flow

User submits query

A user asks: “What are the salary ranges for senior engineers in the New York office?”

TealGuard — PII detection + prompt injection

TealGuard scans the input for PII (names, SSNs, emails) and prompt injection patterns. The query mentions “New York” (a location, not PII in this context) and contains no injection — it passes.

TealEngine — Input policy evaluation

TealEngine evaluates the query against input policies. The topic (salary data) is flagged as sensitive, so the engine sets classification: CONFIDENTIAL on the request context. This classification propagates to all downstream modules.

Retrieval from knowledge base

The RAG system retrieves relevant documents from the vector store: HR salary bands, compensation guidelines, and office-specific adjustments. Some retrieved chunks contain individual employee names and salaries.

TealMemory — Read governance

TealMemory enforces read governance on the retrieved documents. Each document has a classification level. The user’s clearance is checked against the document classification. Documents classified above the user’s level are filtered out before they reach the LLM. Individual salary records (classified RESTRICTED) are excluded — only aggregate band data (classified CONFIDENTIAL) passes through.

LLM generates response

The LLM generates a response using the filtered context: “Senior engineers in the New York office are in Band 7, with a salary range of 180,000180,000–240,000.”

TealGuard — Output content moderation

TealGuard scans the LLM output for content moderation violations and PII leakage. The response contains salary ranges (aggregate, not individual) and no PII — it passes.

TealSecrets — Output secret scan

TealSecrets scans the response for any leaked secrets — API keys, tokens, or credentials that might have been in the retrieved documents. The response is clean.

Response to user

The user receives the salary range information. No individual employee data was exposed.

TealAudit — Full evidence chain

TealAudit logs the complete evidence chain: input scan, classification assignment, documents retrieved, documents filtered by TealMemory, LLM response, output scan results. The correlation ID ties every event together.

Flow Diagram

RAG Application governance flow

Code Example

Key Governance Points

RAG applications are especially vulnerable to indirect prompt injection — malicious instructions embedded in retrieved documents. TealGuard should scan both the user query and the retrieved context before sending to the LLM.
Use TealMemory’s classification levels to implement data loss prevention (DLP) at the retrieval layer. Documents classified as RESTRICTED never reach the LLM, regardless of what the user asks.

TealMemory API

Memory governance scopes and classification enforcement

Guardrail Internals

How TealGuard’s PII detection and content moderation work

Audit & Redaction

How PII is automatically redacted in audit logs

Zero Trust for Agentic AI

Why every step in the pipeline needs governance