RagSentry — pytest for RAG
Regression testing and evaluation CLI for Retrieval-Augmented Generation (RAG) systems.
RagSentry connects to your RAG application through a thin adapter, evaluates retrieved contexts and generated answers against your dataset, tracks runs over time, diffs runs to catch regressions, and gates CI builds.
🚀 Quickstart in 5 Minutes
1. Install RagSentry
pip install ragsentry
(Optional PostgreSQL storage support: pip install ragsentry[postgres])
2. Initialize RagSentry in your project
ragsentry init
This scaffolds:
ragsentry_adapter.py— starter adapter stubevalset.jsonl— starter evaluation set
3. Connect your RAG application
Edit ragsentry_adapter.py to call your RAG pipeline and return the required contract:
from my_rag_app import ask_rag
def query(question: str) -> dict:
result = ask_rag(question)
return {
"answer": result["answer"],
"contexts": result["contexts"], # list[str] of retrieved passages
}
4. Run an Evaluation
Unscored Generation Pass (No LLM required):
ragsentry run -e evalset.jsonl -a ragsentry_adapter:query --no-scoring
Full Evaluation with LLM Judge:
ragsentry run -e evalset.jsonl -a ragsentry_adapter:query -p openrouter -m openai/gpt-oss-120b
5. Diff Runs & Gate CI
Diff two evaluation runs:
ragsentry diff run_2026-09-27T10-00-00_a1b2c3d4.json run_2026-09-27T11-00-00_e5f6g7h8.json
Quality Gate in CI (Exit code 0 on pass, non-zero on failure):
ragsentry ci \
--candidate <candidate_run_id> \
--baseline <baseline_run_id> \
-t faithfulness=0.80 \
-t context_recall=0.85 \
--max-regressed-questions 1 \
--pr-comment-out pr_comment.md
⚡ Key Features
- 🔌 Plug-and-Play Adapters: Supports Python callables (
pkg.mod:func), REST APIs (http://localhost:8000/query), or CLI tools (shell:python rag_cli.py). - 🤖 Provider-Agnostic Judge Scoring: Works with OpenAI, Anthropic, Gemini, Groq, xAI, Ollama, DeepSeek, OpenRouter, or custom OpenAI-compatible endpoints.
- 💾 Dual Storage Backends: Local JSON file store or PostgreSQL (
--storage postgresql://...). - 📊 Rich Terminal Diffs: Colorized diff tables highlighting improved, regressed, and unchanged questions per metric.
- 🚦 CI Quality Gates: Strict threshold enforcement and regression limits with exportable GitHub PR Markdown summaries.
- 🧩 Agent-Usable Scaffolder Skill: Includes
skills/adapter-scaffolderso AI coding assistants can inspect unfamiliar RAG repos and scaffold adapters automatically.
📖 Documentation & Guides
- 📘 Adapter Contract Guide
- 📙 CI / CD Integration Guide
- 📗 Configuration Reference
- 📕 Adapter Scaffolder Skill
📜 License
MIT License.
Metadata
Release files for ragsentry 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ragsentry-0.1.0.tar.gz | 23.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ragsentry-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 51.1 kB
Release files / ragsentry-0.1.0.tar.gz
| Download URL | ragsentry-0.1.0.tar.gz |
|---|---|
| Size | 23.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
45ead8ab53ae4e13a68344e7beab2e2693c5c7652e765759add673e1cfd75dd5
|
|
BLAKE2b-256 checksum How to use checksums |
0cf1d72cb837d84d4399b07fc3d79a918deac6e3e17e946db6423569437b64c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Release files / ragsentry-0.1.0-py3-none-any.whl
| Download URL | ragsentry-0.1.0-py3-none-any.whl |
|---|---|
| Size | 27.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
33a96a40b84753b5800c5c5cd3147fa6016f60be790bf37a2f91fb277eba730f
|
|
BLAKE2b-256 checksum How to use checksums |
f8258806f7d9806bb3d92200c5b5b4d55177cd4d57b5ea9fad4266e46ca3ff0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|