Shawn Mervin

Bedrock Guardrails

AWS's safety layer for generative AI, and the guard on the door into my agent.

Visit aws.amazon.com/guardrailsAWS

What it is

Amazon Bedrock Guardrails is a set of configurable safeguards for generative AI applications. A guardrail can filter harmful content by category and strength, detect prompt attacks, block denied topics and words, and find or mask sensitive information such as card numbers. It can check both what a user sends and what the model returns.

Guardrails can be attached to a Bedrock model call, or used on their own through the ApplyGuardrail API, which checks any text against the policy. That second option works with streamed answers and with models hosted elsewhere. Guardrails are versioned, so an application can pin the exact policy it was tested with.

How I use it

  • Every question is checked before the model sees it, and every answer after. The verdict streams to the page with the rest of the trace.
  • Content filters are set to high, including prompt-attack detection on input.
  • Card numbers, AWS keys and passwords are blocked in either direction.
  • The guardrail is applied on its own with ApplyGuardrail, so the same policy can wrap a streamed answer.
  • On the security page a classic prompt injection is stopped before the model in about 0.3 seconds, for a fraction of a cent.

A guardrail is the right first check whenever strangers can type into a model. It stops the obvious attacks before they cost anything and catches secrets on the way out. I treat it as one layer, not the whole answer: the agent's tools are also small, read-only and capped.

Questions

Can a prompt injection make your agent leak secrets?

The guardrail blocks prompt attacks before the model sees them and blocks AWS keys and passwords in answers. The agent also has no secrets or write access to leak. No single layer is perfect, so there are several.

Does a guardrail slow the agent down?

Barely. A blocked request is stopped in about 0.3 seconds and never reaches Claude, so it is fast and cheap.

Working with Bedrock Guardrails?

Tell me what you're building. Start a project or see the whole stack.

Got an operation that's outgrown its spreadsheets?

Tell me what your business does and where it's jamming up. If I'm not the right person for it, I'll say so and point you somewhere better.

What to send, and what happens next