chapter four

4 Guardrail: A gating mechanism to boost reliability

 

This chapter covers

  • Supporting the reliability and trustworthiness of agentic systems by using guardrails to gate information flow within and around agents
  • Understanding how sequential, parallel, buffered, and streaming guardrails trade off safety, latency, and cost
  • Practical uses of guardrails for safety, compliance, and security

Have you ever tried to trick a chatbot into saying something it shouldn't—maybe that the Steelers are a better team than the Ravens, or that pineapple is the best pizza topping? You may wonder: if chatbots are meant to be general-purpose tools that adapt to user instructions, why do the models powering them have boundaries to keep them from behaving in ways that could reflect badly on their authors?

4.1 The pain point: Unsafe or inappropriate output

4.2 How the Guardrail pattern works

4.2.1 Tradeoffs

4.2.2 When and where to use Guardrail

4.2.3 How Guardrail works with other patterns

4.3 Guardrail pattern variants

4.3.1 Sequential and parallel guardrails

4.3.2 Buffered and stream guardrails

4.3.3 Resampling guardrails

4.4 Applying the Guardrail pattern: Example use cases

4.4.1 Image generation guardrailing

4.4.2 Internal guardrailing in ideation

4.4.3 research agent tools

4.5 Summary