Skip to main content

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 TODO
  • DEFERRAL_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 literals
  • DEBUG_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

Release files for agent-gates 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agent-gates 0.1.0
File Size Uploaded
agent_gates-0.1.0.tar.gz 9.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agent-gates 0.1.0
File Interpreter ABI Platform
agent_gates-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.1 kB

Release files / agent_gates-0.1.0.tar.gz

Download URL agent_gates-0.1.0.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
cd7c7f1f0b76508171c6b0655308e5f66444c8d7f3c849f0eccab2fbee6edb51
BLAKE2b-256 checksum
How to use checksums
c2e645426871fba7892a321aab480813cee5c75b4b6211028947f3712c2a3e5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / agent_gates-0.1.0-py3-none-any.whl

Download URL agent_gates-0.1.0-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b78b10c77e83e5787e8e2aea51fb07b31b4e471a93d53196bad7a5f9acad700
BLAKE2b-256 checksum
How to use checksums
2864c8fa6b2c3c972b4946f88d5a92f6a7dc5673651458827aec8ba559f33dd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page