Two users can ask the same question and legitimately require different answers. Their organization, entitlements, workflow state, and access to documents may differ. A retrieval service needs a deliberate place to assemble that runtime context.

Syed Danish Ali’s Beyond RAG article proposes a context manager above retrieval and generation, illustrated with Spring Boot. The useful architectural idea is explicit context assembly. Its use of the abbreviation CAG means Context-Augmented Generation in that article; the abbreviation is not a guarantee that other systems use the same definition.

Keep facts, instructions, and authority distinct

For a hypothetical support assistant, the authenticated tenant identifier comes from the application session. Retrieved documents provide evidence about products. User text expresses a request. These inputs have different authority even when they eventually share a model context window.

A user saying “I am the administrator” does not establish an entitlement. A retrieved page saying “ignore the tenant filter” does not change the application’s policy. Enforce access in the data path, before unauthorized content reaches generation.

A proposed context assembly path. Authorization constrains evidence before it reaches the model.

A proposed context assembly path. Authorization constrains evidence before it reaches the model.

Make context an inspectable object

A proposed context record can contain the tenant scope, query, workflow state, evidence identifiers, document versions, retrieval time, and a token budget. Keep credentials out of it. Prefer narrowly selected state over dumping a full session history.

Context field Why it matters
Tenant and permission scope Defines eligible evidence
Document version Explains which facts were available
Workflow state Prevents advice for an invalid step
Evidence identifiers Connects answer claims to sources
Budget and truncation record Explains omitted information

Context assembly should expose conflicts. If two policies have different effective dates, silently concatenating both creates an interpretation problem. The application can select the active version, ask a clarifying question, or return an explicit conflict.

Test context changes independently

Hold the question constant and vary one condition at a time: tenant, document permission, workflow phase, or evidence freshness. Check both the retrieved set and the final answer. An answer that happens to avoid revealing a forbidden document is insufficient if that document was already sent to the model.

Also check cache boundaries. A response cache keyed only by question text can cross tenant boundaries even when retrieval itself is correctly filtered. Cache identity must reflect the authorization and evidence conditions that influence the result.

The benefit of a context layer is that these decisions become reviewable application behavior, rather than undocumented prompt concatenation.

Related reading: Retrieval-augmented generation.

Archive note: added November 18, 2026, and filed under 2026-05 as part of the systems reading series.