Skip to content

[Bedrock Flow - Guardrails] - Detect type of blockage

0

Hi everyone,

I have an application developed in Kotlin that uses the aws-sdk-kotlin library version 1.5.75. Using the BedrockAgentRuntimeClient implementation, I call a Flow that was built in the AWS Panel.

This flow has several steps, including a Guardrail. When the Guardrail is triggered, I send it to a specific Output node.

I can capture this node in my application, but I can't figure out the reason/type of the blockage. In fact, I can't even see it in the Flow builder traces.

asked 10 months ago351 views

1 Answer
0

When a guardrail is triggered in your Amazon Bedrock Flow, you can access information about why content was blocked by examining the response fields.

When a guardrail intervenes, the response includes specific fields that indicate the type of blockage:

  1. amazon-bedrock-guardrailAction - This field will show "INTERVENED" when the guardrail blocks content or "NONE" if it doesn't.

  2. amazon-bedrock-trace - This field appears if you enable tracing and contains detailed information about the blocked content, including:

  • The model output that was blocked
  • Assessment details about what triggered the guardrail

The assessment information can include:

  • Topic policies that were violated (with the name of the topic)
  • Content filter violations
  • Custom word violations
  • Sensitive information policy violations

To enable more detailed tracing in your Flow invocation, make sure to set the enableTrace parameter to true in your InvokeFlow request. This will provide you with trace events for each node in your flow, including the guardrail intervention.

For your Kotlin implementation, you should check the response from your flow invocation for these guardrail-specific fields to determine the exact reason for the blockage. The trace information will help you identify whether the content was blocked due to a denied topic, harmful content, sensitive information, or custom word filters.
Sources
Test your guardrail - Amazon Bedrock
Track each step in your flow by viewing its trace in Amazon Bedrock - Amazon Bedrock

answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.