RagLeap
Blog

How to isolate tenants in a RAG app: for_tenant, vector-store filters and the Redis gap (ragleap-rag 0.16.0)

This post explains how to keep each customer's documents apart in a Python RAG application, using the tenant features released in ragleap-rag 0.16.0 (2026-11-15), ragleap-vectorstores 0.7.0 (2026-11-13) and ragleap-agents 0.5.1 (2026-11-14). Facts below come from those release notes and changelogs, checked on 2026-11-15. Status: Released as libraries. Multi-tenant for ragleap-core is Planned, with no date.

Why can a shared RAG index leak between customers?

The dangerous failure is a filter that is silently ignored. The vectorstores 0.7.0 notes record two cases from 0.6.x: the Redis backend ignored filter keys it could not filter on, so a filter such as {"tenant_id": ...} searched every tenant, and the OpenSearch backend silently matched nothing. From 0.7.0 both raise ValueError for keys they cannot filter on.

Runs can leak too. The ragleap-agents 0.5.1 notes describe a gap the authors reproduced with 0.5.0 from PyPI: with one shared agent and one shared state store, tenant B knowing only a run id could resume tenant A's paused run, and the tool executed with A's arguments. Single-tenant use was not affected.

How does ragleap-rag 0.16.0 scope a tenant?

RagLeap.for_tenant(tenant_id) returns a view that tags every ingest with tenant_id, adds it to every search filter, prefixes session ids, and lists, deletes and updates only that tenant's documents. RagLeap(..., require_tenant=True) makes unscoped calls raise TenantRequiredError. Default behaviour is unchanged, and documents ingested without a tenant tag are not visible through a view. Tenant ids are 1 to 128 characters from A-Z a-z 0-9 _ . @ -, because the id is put into filter expressions.

Which vector stores can filter by tenant?

In ragleap-vectorstores 0.7.0, tenant_id is a filterable field in the Redis backend (a TAG field), the OpenSearch backend (a keyword, also mapped on existing indexes) and the LanceDB backend (a nullable column, added to existing tables). Chunks without a tenant tag never match a tenant_id filter. The ragleap-rag 0.16.0 upgrade note says tenant views on these three backends need ragleap-vectorstores>=0.7.0. A Redis index created before 0.7.0 has no tenant_id field, and filtering by it raises RuntimeError, so use a new index_name. The notes do not claim anything about tenant filtering on other backends, so test yours before relying on it.

The releases also close a related hole. In ragleap-rag 0.16.0, caller metadata can no longer overwrite the stored chunk fields (document_id, document_name, chunk_index) in the Pinecone, Qdrant, Milvus and Weaviate backends, and the Milvus filter now escapes string values. In ragleap-vectorstores 0.7.0 the same is fixed for Chroma (document_id, document_name, chunk_index and token_count).

What about agent runs and approvals?

ragleap-agents 0.5.1 adds run(task, *, scope=None, tainted=False) and resume(run_id, decisions, *, scope=None). A run saves its scope, and resume continues it only for exactly the same scope. A wrong scope, an unknown run and a damaged state all raise the same ResumeError("unknown run"). Agent(..., require_scope=True) refuses unscoped runs, and sub-agents inherit the parent's scope. New run ids are 22-character URL-safe tokens (128 bits) instead of 12 hex characters; old ids still load and resume. The new dependency is ragleap-security 0.2.0 or newer.

How can I test that isolation works?

This is our suggestion, not a claim from the release notes. Ingest a document for tenant A and one for tenant B in the real backend you use. Search as A and check that no chunk of B comes back. Call without a tenant while require_tenant=True and check that it raises. Resume a paused run with the wrong scope and check that it refuses. Run these against the real store, not a mock, because the Redis gap above only showed up on a real backend.

What is not covered?

  • The caller must pass the right scope. The library does not log users in.
  • A tool that reads another tenant's data by itself is not stopped.
  • A shared store file shows every tenant to anyone with access to the file. Use one store per tenant for stronger separation.
  • An in-memory rate limiter is lost on restart.
  • No independent security review has happened.
  • ragleap-core itself is single-tenant. Multi-tenant for it is Planned, with no date.

Sources: the GitHub release notes for ragleap-rag 0.16.0, ragleap-vectorstores 0.7.0 and ragleap-agents 0.5.1. Library pages: ragleap-rag, ragleap-vectorstores and ragleap-agents.

Quick answers

How do I do multi-tenant RAG in Python without leaking documents?

Tag every chunk with a tenant id when you ingest, add that id to every search filter, and test that a query as tenant A never returns tenant B's chunks. ragleap-rag 0.16.0 does the first two through RagLeap.for_tenant(tenant_id).

What does RagLeap.for_tenant do?

It returns a view that tags every ingest with tenant_id, adds it to every search filter, prefixes session ids, and lists, deletes and updates only that tenant's documents. require_tenant=True makes unscoped calls raise TenantRequiredError.

Which vector stores need ragleap-vectorstores 0.7.0 for tenant views?

Redis, OpenSearch and LanceDB. On 0.6.x those backends ignore the tenant filter or cannot filter by tenant_id.

Is ragleap-core multi-tenant?

No. Multi-tenant for ragleap-core is Planned, with no date. The tenant scope described here is a feature of the libraries.

Back to the blog