A lightweight guardrails framework for AI agents that supports multiple languages, primarily Arabic and its dialects, for safety and PII governance.
Project description
Qarai Agent Guard
Qarai Agent Guard is a lightweight, composable guardrails framework for AI agents. It inspects agent memory and tool I/O at runtime, detects unsafe or sensitive content, and enforces policy-driven actions — block, warn, redact, or allow — before data is persisted or returned to users.
The project is built with multilingual safety in mind. Arabic is a first-class language today, with pattern libraries and detectors tuned for Modern Standard Arabic. Arabic dialects (Maghrebi, Egyptian, Levantine, Gulf, and others) are on the roadmap, reflecting the linguistic diversity of real-world deployments across the MENA region and the global Arabic-speaking diaspora.
Whether you run agents in English, French, Arabic, or a mix of languages, Qarai Agent Guard gives you a single, policy-driven layer to govern PII, secrets, prompt injection, and model-reasoning leakage — without rewriting your agent stack.
Why Qarai Agent Guard?
AI agents accumulate context in memory, call external tools, and exchange messages across sessions. That context is a high-value attack surface: prompt injection can poison long-term memory, PII can leak into logs, and chain-of-thought content can surface where it should not.
Qarai Agent Guard addresses this by sitting between your agent and its memory layer, running detectors on every create, read, update, and delete operation. Policies map detection severity to concrete actions so security teams can tune behavior without touching application code.
| Capability | Description |
|---|---|
| Multilingual detection | YAML-driven regex patterns for English, French, and Arabic; extensible to dialects |
| Policy engine | Severity-based rules: block, redact, warn, allow |
| Memory governance | Hooks on all CRUD paths for agent memory |
| Framework integrations | LangChain buffer memory support out of the box |
| Composable detectors | PII, secrets, model-reasoning / injection patterns |
| Custom policies | Built-in presets or load your own YAML policy files |
Quick start
Install the package (see install.md for full instructions):
pip install qarai-agent-guard
# LangChain integration (optional)
pip install langchain-community
Configure guards and attach them to LangChain buffer memory:
from qarai_agent_guard import (
BufferMemoryMiddleware,
GuardedBufferChatMessageHistory,
ModelReasoningDetector,
PIIDetector,
strict_policy,
)
middleware = BufferMemoryMiddleware(
detectors=[
ModelReasoningDetector(lang="ar"),
PIIDetector(),
],
policy=strict_policy(),
)
history = GuardedBufferChatMessageHistory(
middleware=middleware,
session_id="user-42",
)
history.add_user_message("مرحبا، كيف يمكنني المساعدة؟")
You pass detectors and policy to BufferMemoryMiddleware. The library wires AgentGuard, MemoryGuard, and the internal middleware for you.
Documentation
| Document | Description |
|---|---|
| install.md | Installation, dependencies, and environment setup |
| contributing.md | How to contribute code, patterns, and documentation |
| docs/index.md | Component reference and architecture guide |
Project status
Qarai Agent Guard is under active development. The core detector, policy, and guard pipeline is stable; integrations and dialect coverage are expanding. We welcome contributions — especially Arabic dialect patterns, new integrations, and policy presets.
License
Apache License 2.0. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qarai_agent_guard-0.1.0.tar.gz.
File metadata
- Download URL: qarai_agent_guard-0.1.0.tar.gz
- Upload date:
- Size: 29.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a3e2a79be19d64af226557ee4e438469e470cab3e7e364faf1c45b6c82517df
|
|
| MD5 |
fd4b0bb6e4cce75ae1dcffeb43115cdd
|
|
| BLAKE2b-256 |
4ff5f768acc349a41865753f3e8e2cda15e042f77c7341c64cfda39613f309be
|
File details
Details for the file qarai_agent_guard-0.1.0-py3-none-any.whl.
File metadata
- Download URL: qarai_agent_guard-0.1.0-py3-none-any.whl
- Upload date:
- Size: 32.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84e2413b1c91cd40bba9e5d8ecfd78f08f2573ade7814fb3e6af11c9d54587b1
|
|
| MD5 |
398f51cac36fc6b942d34d2e851a6fcf
|
|
| BLAKE2b-256 |
2fd46a0f2b4393454654bbe106e4eaa5600bb6b3bede03b78a675b4db45e6351
|