0

Responsible AI — Guardrails

Apply Bedrock Guardrails to Managed Knowledge Bases for content safety and grounding checks.

Example · مثالaws

Content

Responsible AI — Guardrails

Apply Bedrock Guardrails to Managed Knowledge Bases for content safety and grounding checks.

| # | Notebook | Description | |---|----------|-------------| | 01 | 01-guardrails-with-bmkb.ipynb | Bedrock Guardrails integration with AgenticRetrieveStream | | 02 | 02-guardrails-contextual-grounding-with-bmkb.ipynb | Contextual grounding — detect and block hallucinated responses |

How Guardrails work with Managed KBs

Guardrails are applied via the policyConfiguration parameter in AgenticRetrieveStream:

response = runtime_client.agentic_retrieve_stream(
    ...,
    policyConfiguration={
        'guardrailId': 'your-guardrail-id',
        'guardrailVersion': 'DRAFT',
    },
)

Contextual grounding

Checks whether the generated response is:

  1. Grounded — factually supported by the retrieved source chunks
  2. Relevant — answers the user's actual question

If either check fails → response is BLOCKED.

Limitations

  • Only BLOCK action is supported (not MASK) with AgenticRetrieveStream
  • Grounding source limit: 100,000 characters
  • Query limit: 1,000 characters
  • Response limit: 5,000 characters

Documentation

Source and license

Source
Amazon Bedrock Samples
Original
aws-samples/amazon-bedrock-samples/rag/managed-knowledge-bases/06-Responsible AI
License
MIT