Quality gates for AI agent output validation
Project description
Agent Gates
Quality gates for AI agent output validation.
A framework for validating AI agent outputs with configurable gates. Designed for Claude, GPT, and other LLM-based agents.
Installation
pip install agent-gates
Quick Start
from agent_gates import GatePipeline
# Use a preset pipeline
pipeline = GatePipeline.from_preset("standard")
result = pipeline.check("This should work")
if not result.passed:
print(result.to_markdown())
Presets
| Preset | Description |
|---|---|
strict |
All gates as blocking - no hedging, no apologies, no assumptions |
standard |
Common gates with sensible defaults |
minimal |
Only critical gates (hedging, unverified claims, credentials) |
code_review |
Focused on code quality (TODOs, debug prints, magic numbers) |
Custom Gates
from agent_gates import Gate, GatePipeline
# Create a custom gate
no_emoji = Gate(
name="no_emoji",
pattern=r"[\U0001F600-\U0001F64F]",
action="warn",
message="Response contains emoji",
suggestion="Remove emoji for professional output"
)
# Build a custom pipeline
pipeline = GatePipeline("my_pipeline")
pipeline.add_gate(no_emoji)
# Or combine with a preset
pipeline = GatePipeline.from_preset("standard")
pipeline.add_gate(no_emoji)
Gate Types
Language Gates
HEDGING_GATE- Blocks "should work", "might be", "probably"APOLOGY_GATE- Blocks "I apologize", "sorry for"SYCOPHANCY_GATE- Blocks "great question", "you're absolutely right"ASSUMPTION_GATE- Warns on "I'll assume", "let's assume"
Verification Gates
UNVERIFIED_CLAIM_GATE- Blocks claims without verification evidence
Completeness Gates
TODO_GATE- Blocks incomplete work marked as TODODEFERRAL_GATE- Blocks "I'll do it later", "for now"
Security Gates
CREDENTIAL_GATE- Blocks exposed passwords, API keys, tokens
Code Review Gates
MAGIC_NUMBER_GATE- Info on large numeric literalsDEBUG_PRINT_GATE- Warns on console.log, print()COMMENTED_CODE_GATE- Info on commented-out code
API Reference
Gate
Gate(
name: str, # Unique identifier
pattern: str = None, # Regex pattern (match = failure)
check_fn: Callable = None, # Custom function (True = failure)
escape_pattern: str = None, # Pattern that exempts from check
action: str = "block", # "block", "warn", or "info"
message: str = "", # Human-readable failure message
suggestion: str = "", # How to fix the issue
category: str = "custom", # Category for grouping
enabled: bool = True # Can be disabled dynamically
)
GatePipeline
pipeline = GatePipeline(name="my_pipeline")
pipeline.add_gate(gate) # Add a gate
pipeline.remove_gate("name") # Remove by name
pipeline.disable_gate("name") # Disable temporarily
pipeline.enable_gate("name") # Re-enable
result = pipeline.check(text) # Run all gates
GateResult
result.passed # bool - True if no blocking failures
result.failures # list[GateFailure] - blocking issues
result.warnings # list[GateFailure] - non-blocking issues
result.info # list[GateFailure] - informational
result.to_markdown() # Formatted output
result.to_dict() # Serializable dict
Utility Functions
from agent_gates import quick_check, get_failures
# Boolean check
if quick_check(text, "standard"):
print("Passed!")
# Get failure messages
failures = get_failures(text, "strict")
for msg in failures:
print(msg)
Serialization
Pipelines can be serialized for storage or configuration:
# Save
config = pipeline.to_dict()
json.dump(config, open("pipeline.json", "w"))
# Load
config = json.load(open("pipeline.json"))
pipeline = GatePipeline.from_dict(config)
License
MIT
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
agent_gates-0.1.0.tar.gz
(9.6 kB
view details)
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 agent_gates-0.1.0.tar.gz.
File metadata
- Download URL: agent_gates-0.1.0.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd7c7f1f0b76508171c6b0655308e5f66444c8d7f3c849f0eccab2fbee6edb51
|
|
| MD5 |
f50b590d123ff0039f29f81f7efc2246
|
|
| BLAKE2b-256 |
c2e645426871fba7892a321aab480813cee5c75b4b6211028947f3712c2a3e5d
|
File details
Details for the file agent_gates-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agent_gates-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b78b10c77e83e5787e8e2aea51fb07b31b4e471a93d53196bad7a5f9acad700
|
|
| MD5 |
b9a95877ad90190048a82ca522eb9433
|
|
| BLAKE2b-256 |
2864c8fa6b2c3c972b4946f88d5a92f6a7dc5673651458827aec8ba559f33dd4
|