Catalog PyPI
Back to packageRELEASE DETAILS

5.0.0

PyPI

agent-rag-governance

Retrieval access control and vector store policy enforcement for RAG pipelines

access-controlai-agentsauditcomplianceenterprise-aigovernancelangchainllamaindexpolicy-enforcementragretrieval-augmented-generationvector-store
Published3 Aug 2026
Direct dependencies6
Transitive dependenciesNot calculated

README

Version 5.0.0 documentation

agent-rag-governance

Retrieval access control and vector store policy enforcement for RAG pipelines.

Part of the Agent Governance Toolkit.

The Gap This Fills

AGT covers write-time memory protection (MemoryGuard) and output quality (ContentGovernance) — but nothing at retrieval time. Without retrieval-level governance:

  • An agent can query any collection it wants — no access control
  • No audit trail of which documents influenced an answer
  • No rate limiting if an agent gets stuck in a retrieval loop
  • No content scanning before retrieved chunks reach the LLM

agent-rag-governance closes that gap.

Quick Start

pip install agent-rag-governance
from agent_rag_governance import RAGGovernor, RAGPolicy

policy = RAGPolicy(
    allowed_collections=["public_docs", "product_manuals"],
    denied_collections=["hr_records", "financial_data"],
    max_retrievals_per_minute=100,
    content_policies=["block_pii", "block_injections"],
    audit_enabled=True,
)

governor = RAGGovernor(policy=policy, agent_id="sales-agent-001")
governed_retriever = governor.wrap(your_langchain_retriever, collection="public_docs")

# Drop-in replacement — same API as the original retriever
docs = governed_retriever.invoke("what is our refund policy?")

What It Enforces

LayerWhat It Does
Collection access controlAllow/deny lists per agent — blocks cross-tenant data leaks
Rate limitingSliding-window cap on retrievals/min — stops runaway loops
Content scanningPII and prompt-injection detection on chunks before LLM sees them
Audit loggingStructured JSON-lines record per call — enables EU AI Act traceability

Governance Pipeline

Every governed_retriever.invoke(query) call runs this sequence:

1. check_collection()   →  CollectionDeniedError if blocked
2. check_rate()         →  RateLimitExceededError if exceeded
3. retrieve()           →  calls underlying retriever
4. scan_chunks()        →  filters blocked chunks, logs warnings
5. audit()              →  emits JSON-lines audit entry

Policy Reference

RAGPolicy(
    # None = allow all (unless denied). List = explicit allow list.
    allowed_collections=["public_docs"],

    # Always blocked, even if in allowed_collections.
    denied_collections=["hr_records", "financial_data"],

    # 0 = unlimited. Per agent per 60-second sliding window.
    max_retrievals_per_minute=100,

    # "block_pii": block chunks with emails, phones, SSNs, credit cards
    # "block_injections": block chunks with prompt-injection payloads
    content_policies=["block_pii", "block_injections"],

    # Write structured JSON-lines audit entries.
    audit_enabled=True,

    # None = stdout. Provide a path for file-based logging.
    audit_log_path="/var/log/rag-audit.jsonl",
)

Audit Log Format

Each retrieval call emits one JSON line:

{
  "timestamp": "2026-05-05T12:34:56.789012+00:00",
  "agent_id": "sales-agent-001",
  "collection": "public_docs",
  "query_hash": "a3f1...",
  "num_chunks_retrieved": 5,
  "num_chunks_blocked": 1,
  "decision": "allowed",
  "policy_triggered": null
}

Raw query text is never logged — only a SHA-256 hash — to avoid leaking sensitive search terms.

Compatibility

Works with any retriever that implements .invoke() or .get_relevant_documents(). LangChain is an optional dependency — agent-rag-governance has no required framework dependencies.

# With LangChain integration
pip install "agent-rag-governance[langchain]"
PackageProtects
agent-os-kernel (MemoryGuard)Write-time memory poisoning
agent-rag-governanceRetrieval-time access control
agent-os-kernel (ContentGovernance)Output-time quality enforcement

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 8

Native requirements
6 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
pydantic
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.11",
  "evaluation": "NOT_EVALUATED"
}
pydantic<3.0,>=2.4.0runtime
langchain-core
Environment
{
  "extras": "",
  "marker": "extra == \"langchain\"",
  "requires_python": ">=3.11",
  "evaluation": "NOT_EVALUATED"
}
langchain-core>=0.2.0; extra == "langchain"runtime
llama-index-core
Environment
{
  "extras": "",
  "marker": "extra == \"llamaindex\"",
  "requires_python": ">=3.11",
  "evaluation": "NOT_EVALUATED"
}
llama-index-core>=0.10.0; extra == "llamaindex"runtime
pytest
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.11",
  "evaluation": "NOT_EVALUATED"
}
pytest==9.1.1; extra == "dev"runtime
pytest-asyncio
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.11",
  "evaluation": "NOT_EVALUATED"
}
pytest-asyncio==1.4.0; extra == "dev"runtime
ruff
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.11",
  "evaluation": "NOT_EVALUATED"
}
ruff>=0.4.0; extra == "dev"runtime
pytest
Environment
{
  "extras": "",
  "marker": "extra == \"test\"",
  "requires_python": ">=3.11",
  "evaluation": "NOT_EVALUATED"
}
pytest==9.1.1; extra == "test"runtime
pytest-asyncio
Environment
{
  "extras": "",
  "marker": "extra == \"test\"",
  "requires_python": ">=3.11",
  "evaluation": "NOT_EVALUATED"
}
pytest-asyncio==1.4.0; extra == "test"runtime

Distribution files

2 collected
agent_rag_governance-5.0.0-py3-none-any.whl

bdist_wheel · 23.47 KB · Python py3

Source file
agent_rag_governance-5.0.0.tar.gz

sdist · 31.79 KB · Python source

Source file

Repository

PENDING
microsoft/agent-governance-toolkit

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 23:06 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:8d921cc2d0fa36039ed5d66baeb6fc7222ffd6ee05e403871ab6646b59a964fd

Other collected versions

View all collected versions →