Guardrail
A guardrail is a constraint, control, or monitoring mechanism that limits system behavior to reduce risks and keep actions or outputs within acceptable bounds.
The Art of AI Product Development
A guardrail is a constraint or control mechanism that limits an AI system's behavior to reduce harmful, unsafe, or noncompliant outputs.
- How it is used
- Uses guardrails to constrain AI responses and actions according to product risks, compliance requirements, and user needs.
- How deep it goes
- Describes control options and practical safeguards, including approval steps and refusal examples, without detailed implementation code.
- Examples
- Illustrates guardrails with a financial chatbot, an editing assistant that declines off-topic requests, and an agent handling financial transactions.
- What you can do after
- Evaluate and apply safeguards for response scope and high-stakes actions, including refusal examples and human approval.
Read how The Art of AI Product Development explains guardrail →
Natural Language Processing in Action, Second Edition
A guardrail is a constraint or control that limits a language-model system's behavior to improve safety, reliability, or adherence to requirements.
- How it is used
- Limits unsafe or unsuitable behavior in language-model applications, particularly when users receive responses without continuous human monitoring.
- How deep it goes
- Demonstrates prompt checks, output checks, and fuzzy matching, then discusses adversarial testing and guardrail bypasses.
- Examples
- Uses an unusual-prompt validator, a misspelled drug-brand matcher, and a math chatbot’s response to an out-of-scope loan request.
- What you can do after
- Apply guardrails via Guardrails AI and spaCy, and evaluate their limitations through authorized red teaming.
Read how Natural Language Processing in Action, Second Edition explains guardrail →
Designing AI Systems
A guardrail is an execution policy that constrains AI system inputs, actions, and outputs according to safety, business, permission, or regulatory requirements.
- How it is used
- Enforces shared safety, business, permission, and regulatory policies across AI interactions and tool execution.
- How deep it goes
- Details five inspection points, a service contract, policy configuration, approval workflows, observability, and safe rollout.
- Examples
- Uses patient intake policies, appointment argument validation, conflicting tool calls, and surgical booking approval to illustrate enforcement.
- What you can do after
- Operate and configure guardrails through named policies, inspection checks, approval gates, and monitoring records.
Machine Learning Platform Engineering
A safety filter is a model-level mechanism that blocks or restricts generated content belonging to configured harmful-content categories.
- How it is used
- Protects production LLM and public-facing RAG applications against harmful outputs and policy violations.
- How deep it goes
- Shows layered placement, Guardrails AI input validation, and model harm-category thresholds; does not detail the filters’ internal classification.
- Examples
- Uses category-specific blocking thresholds, email redaction, competitor-mention rejection, and a guarded documentation assistant.
- What you can do after
- Apply it via Guardrails AI validators and configure model harm-category thresholds within a layered LLM request path.
Read how Machine Learning Platform Engineering explains guardrail →
AI Agents in Action, Second Edition
A guardrail is a constraint, check, or control that limits an AI system's reasoning or actions.
- How it is used
- Protects agent inputs, outputs, and high-stakes handoffs from invalid or risky data.
- How deep it goes
- Works through layered validation, tripwire handling, and bounded retries, including the SDK's handoff limitation.
- Examples
- Uses research-plan length checks and grounding checks for retrieval-augmented answers.
- What you can do after
- Applies guardrails via the OpenAI Agents SDK, handling tripwires with retries or a static response.
Read how AI Agents in Action, Second Edition explains guardrail →
Fundamentals of Cybersecurity
A safeguard or countermeasure that protects organizational assets and reduces the likelihood or impact of vulnerability exploitation.
- How it is used
- Protects organizational assets by reducing vulnerabilities and the likelihood or impact of threats.
- How deep it goes
- Defines safeguards, explains risk-based selection, compares categories and functions, and describes layering without giving a detailed implementation procedure.
- Examples
- Compares laptop authentication with website protections and pairs locks, intrusion detection, and policies with distinct control functions.
- What you can do after
- Evaluate/understand it by matching controls to asset risks, comparing their functions, and weighing risk reduction against operational costs.
AI-Powered Search
A guardrail is a constraint that limits system behavior to prevent inappropriate, unsafe, or irrelevant outcomes.
- How it is used
- Restricts search personalization to past interactions relevant to the current query.
- How deep it goes
- Works through category generation, cluster inspection, interaction filtering, and result reranking.
- Examples
- Compares filtered and unfiltered personalization for a microwave query after interactions with a water bottle and electric range.
- What you can do after
- Apply guardrails using K-means clusters and embedding similarity to filter interactions before personalizing search results.
AI Governance
A control that constrains AI system inputs, outputs, or interactions to reduce safety, security, or policy violations.
- How it is used
- Uses guardrails to screen AI interactions within production safety and security workflows.
- How deep it goes
- Explains input and output placement, bypass paths, customization, and operational controls without providing a complete implementation.
- Examples
- Uses a dealership chatbot’s unauthorized offer and an insurance-claims assistant’s forbidden-topic rules to illustrate failures and customization.
- What you can do after
- Operate and configure layered input and output screening, validate it against deployment examples, and pair it with monitoring and human review.
AI Agents and Applications
A guardrail is a constraint or control that limits model behavior to satisfy safety, quality, or policy requirements.
- How it is used
- Keeps agents within application scope and policy by checking requests, responses, and actions at workflow boundaries.
- How deep it goes
- Implements router and agent input checks with a classifier, while outlining post-model checks as production extensions.
- Examples
- Uses a travel assistant to reject sports questions at the router and Liverpool travel requests at Cornwall-only agents.
- What you can do after
- Applies guardrails with LangGraph routing and pre-model hooks to classify requests and direct out-of-scope inputs toward refusal.
Effective Conversational AI
A guardrail is a constraint, control, or oversight mechanism that limits unsafe, unsuitable, or undesired behavior by an AI system.
- How it is used
- Limits risk when an LLM assists a conversational AI system or responds directly to its users.
- How deep it goes
- Explains model selection, input screening, and prompt context, then tests a dialogue-flow failure without detailing filter implementation.
- Examples
- Uses disguised harmful requests, a chatbot’s nonexistent discount, and a claim-status dialogue that stalls when information is missing.
- What you can do after
- Practice/perform it: combine task-appropriate model selection, input screening, prompt guidance, and repeated testing before trusting user-facing output.
LLMs in Production
A guardrail is a constraint or control intended to keep a language model's behavior within acceptable safety or policy boundaries.
- How it is used
- Keeps an LLM agent on task while applications face ethical and legal uncertainty.
- How deep it goes
- Connects guardrails to fine-tuning and prompt engineering, but does not specify implementation patterns or evaluation procedures.
- Examples
- Uses a car-selling chatbot, saved logs, and customer chat history as concrete operational cases.
- What you can do after
- Operate/configure an LLM application by setting guardrails, refining prompts, and preserving logs and customer chat history.
Introduction to Generative AI, Second Edition
A safety filter is a control that detects or blocks inputs or outputs that violate defined safety restrictions.
- How it is used
- Controls model outputs and agent actions when safety policies must constrain otherwise useful AI behavior.
- How deep it goes
- Explains policy goals, classifiers, permissions, approval, and monitoring, but stops short of implementation details.
- Examples
- Uses Bing topic restrictions, toxicity classification, agent permission gating, approval pauses, audit logs, and anomaly detection.
- What you can do after
- Evaluate/understand how safety controls balance helpfulness against harm and constrain model outputs or agent actions.
Read how Introduction to Generative AI, Second Edition explains guardrail →
Architecting for Autonomy
An architectural control that constrains autonomous system behavior at runtime, independently of the agent's own reasoning.
- How it is used
- Bounds delegated autonomous decisions at runtime while preserving room for different paths to safe outcomes.
- How deep it goes
- Defines executable control types and explains their relationship to policy, without specifying model-level implementation.
- Examples
- Uses a contract-dispute drafting scenario to illustrate document filtering, redaction, grounding limits, and denial of external tool access.
- What you can do after
- Evaluate and understand where independent controls enforce policy boundaries and where checks alone cannot establish policy meaning.
Financial AI in Practice
A guardrail is a constraint or control that limits model behavior to reduce unwanted or unsafe outputs.
- How it is used
- Constrains financial AI inputs, outputs, recommendations, and agent actions within security, operational, and regulatory boundaries.
- How deep it goes
- Identifies control points, example rules, and audit logging, but does not specify their implementation in the supplied excerpts.
- Examples
- Illustrates objective financial-news summaries and retention-agent rules for communication frequency, product suitability, timing, and compliance review.
- What you can do after
- Evaluate a financial AI workflow for input, output, tool-permission, and governance controls.
Vibe Engineering
A guardrail is a constraint or control that limits an AI system's actions to reduce unsafe, unauthorized, or unreliable outcomes.
- How it is used
- Limits risks as AI workflows move from supervised autocomplete toward autonomous agents and external tool use.
- How deep it goes
- Explains where controls must move as autonomy increases, while deferring detailed treatment of external-tool security, authentication, logging, and governance.
- Examples
- Uses a Cloud Run deployment prompt and a dictionary-size constraint to illustrate steering infrastructure and cache design.
- What you can do after
- Evaluate guardrail placement and specify deployment or data constraints when requesting AI-generated solutions.
Decision Engineering
A boundary or guideline that constrains choices while allowing teams to make decisions within it.
- How it is used
- Narrows technology choices before individual teams make decisions, reducing repeated analysis of organization-level concerns.
- How deep it goes
- Defines the strategic role of guardrails and illustrates several forms, without prescribing a procedure for creating or enforcing them.
- Examples
- Uses Java versus C# consolidation, Azure versus other cloud providers, and common logging, API, and design standards.
- What you can do after
- Practice/perform it by screening technology options against organizational boundaries and identifying when an exception needs justification.
Understanding AI
A safety guardrail is a learned constraint on whether and how a model responds to requests that could cause harm or involve disallowed content.
- How it is used
- Shapes an assistant’s communication and boundaries during interaction.
- How deep it goes
- Explains guardrails through human rankings, reward modeling, and updates, while stopping short of mathematical detail.
- Examples
- Uses polite refusals of dangerous instructions and reviewer rankings of competing responses.
- What you can do after
- Evaluate refusals and redirections as learned alignment behaviors rather than assuming a fixed forbidden-topic list.
Effective Data Analysis
A guardrail is a predefined criterion or control intended to maintain analytical accuracy, protect individuals, and constrain harmful or unreliable interpretations.
- How it is used
- Uses predefined controls to protect people and constrain inaccurate or biased interpretations of sensitive analytical data.
- How deep it goes
- Specifies practical anonymity, aggregation, reporting, and communication rules, then extends them to proposed clinical-trial guidelines.
- Examples
- Uses an employee engagement survey, small-subgroup suppression, synthesized comments, and clinical-trial reporting exercises.
- What you can do after
- Apply guardrails by weighing protection methods and proposing reporting guidelines for clinical-trial results.
Effective Platform Engineering
A guardrail is a control that constrains system behavior by preventing or flagging operations outside an allowed threshold or policy.
- How it is used
- Uses deployment-time checks to preserve team pipeline autonomy while enforcing governance and compliance.
- How deep it goes
- Explains the compliance-work and verification split and names validating webhooks, but stops short of webhook implementation details.
- Examples
- Uses a Kubernetes admission controller and Gatekeeper policy that checks labels on deployments.
- What you can do after
- Operate Kubernetes admission validation that intercepts deployments and verifies required compliance conditions.
Read how Effective Platform Engineering explains guardrail →
Software Architecture Decision-Making
A guardrail is a constraint or shared convention that enables local autonomy while preserving system-wide coherence.
- How it is used
- Enables autonomous teams to make local decisions while preserving coherent boundaries, interactions, and cross-cutting practices.
- How deep it goes
- Defines guardrails through concrete rule categories and ownership responsibilities, but stops short of prescribing implementation procedures.
- Examples
- Uses APIs, versioning rules, ownership boundaries, observability expectations, security standards, and deployment conventions as examples.
- What you can do after
- Evaluate and adapt shared constraints so teams move independently without creating fragmentation or unclear cross-cutting ownership.
Read how Software Architecture Decision-Making explains guardrail →
Machines that Think
A guardrail is a control, restriction, or monitoring mechanism designed to limit an AI system's harmful or unacceptable behavior.
- How it is used
- Limits the consequences of unreliable model behavior by constraining operations and complementing statistical alignment.
- How deep it goes
- Describes operational containment, structured prompting, monitoring, and iterative adjustment, but gives no implementation detail.
- Examples
- Names sandboxed code generation, approved-source retrieval, explicit tool interfaces, structured prompts, examples, and output review.
- What you can do after
- Evaluate model reliability as a system-level concern and identify containment, monitoring, and oversight measures.
Think Like a CTO
A software guardrail is a software-enforced constraint or check that prevents unsafe, invalid, or unintended operations.
- How it is used
- Uses guardrails during incident investigation to prevent recurring operational failures.
- How deep it goes
- Defines guardrails through a workplace failure example but stops short of implementation-level detail.
- Examples
- Uses a visually distinctive production terminal as a safeguard against deleting the wrong server cluster.
- What you can do after
- Diagnose operational failures and select safeguards, retraining, or additional reviews as corrective responses.
Building Reliable AI Systems
A constraint that defines behavior a model should or should not exhibit.
- How it is used
- Keep agent responses within intended capabilities and safe, travel-focused boundaries.
- How deep it goes
- Define boundaries and demonstrate keyword filtering, while warning that brittle matching falls short of semantic, multilayer safety.
- Examples
- Filter categories such as crypto, medical, legal, personal data, and harmful content in a travel-assistant scenario.
- What you can do after
- Build a basic Python keyword filter that rejects text matching blocked categories, while recognizing its synonym-bypass weakness.
Also covered in
- Enterprise RAGIn early access (MEAP)
- "Looks Good to Me"
- Software Testing with Generative AI
- Claude at WorkIn early access (MEAP)
- Generative AI in Action
- Build an Advanced RAG Application (From Scratch)In early access (MEAP)
- Designing AI AgentsIn early access (MEAP)
- Spring AI in Action
- WordPress Power Toolkit: Harness AI to build next-level websites
- AI Model EvaluationIn early access (MEAP)
- LLM Evaluation and Alignment, The Foundational IdeasIn early access (MEAP)
- Digital Twins in Action
What to know first
- language modelA language model is a computational model that represents patterns in linguistic sequences to assign probabilities, predict, generate, or evaluate language.
- AI agentAn AI agent is a computational system that uses artificial intelligence to interpret information and select or perform actions toward goals while interacting with an environment.
- promptA prompt is text or other input supplied to an AI model to provide instructions, context, or other information that guides its response or generated output.
- fine-tuningFine-tuning is the continued training of a pretrained model on targeted data or objectives to adapt its parameters or behavior to a task, domain, or use.
Related concepts
- defense in depthused by · A strategy that applies multiple complementary protective controls so that the failure or bypass of one does not eliminate protection.
- execution environmentkind of · An execution environment is the computational context in which a program runs, including its supporting software, available resources, and relevant system state or configuration.
- prompt injectionaddresses · Prompt injection is an attack that introduces instructions through input or context to manipulate an AI system’s behavior or override its intended instructions.
- administrative controlincludes · An administrative control is an organizational safeguard comprising policies, procedures, training, or oversight that governs security-related behavior and activities.
- agent flowuses · An agent flow is a multi-agent coordination pattern in which agents communicate directly without a central command or control component.
- agentic RAGconfigures · Agentic RAG is a retrieval-augmented generation approach in which an agent dynamically decides how and when to retrieve information, often iterating or using tools before generating a response.
Questions about guardrail
What is guardrail?
A guardrail is a constraint, control, or monitoring mechanism that limits system behavior to reduce risks and keep actions or outputs within acceptable bounds.
Which Manning books explain guardrail?
The Art of AI Product Development, Natural Language Processing in Action, Second Edition, Designing AI Systems, Machine Learning Platform Engineering, AI Agents in Action, Second Edition, Fundamentals of Cybersecurity, AI-Powered Search, AI Governance and 15 more.
What should I know before learning guardrail?
Manning books that teach guardrail usually introduce language model, AI agent, prompt and fine-tuning first.
What kinds of guardrail are there?
Kinds of guardrail include administrative control.
What is guardrail a kind of?
Guardrail is a kind of execution environment. An execution environment is the computational context in which a program runs, including its supporting software, available resources, and relevant system state or configuration.
What is guardrail also called?
Guardrail is also called safeguards or guard rails.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.






















