Where Guardrails Fit
Validate before and after generation
A guardrail is a control that constrains what an AI application accepts, does, or returns. Input guardrails run before expensive inference. Tool guardrails run before actions. Output guardrails run before a response reaches a user or downstream program.
Common input rules include maximum characters, allowed languages, blocked instruction patterns, and required fields. Common output rules include valid JavaScript Object Notation (JSON), required keys, allowed status values, maximum length, and absence of secrets.
Analogy: Airport screening happens at several doors: ticket validation before entry, permission checks before restricted areas, and customs before exit. One checkpoint cannot enforce every rule.
Scenario: An application promises{answer, status}JSON, but its policy requires onlyanswerand allows adebugstatus. Internal traces can reach clients and automation cannot distinguish a valid response from an incomplete one.
Enforce deterministic contracts in application code. Asking the model to 'please return valid JSON' is guidance, not validation. Invalid output must be rejected, repaired through a bounded explicit path, or returned as a controlled error.