Blocking Harmful Prompts and Streaming Bedrock Guardrail Filters
A social messaging company is building an AI chat assistant by using Amazon Bedrock. The company must ensure that every inference complies with an approved safety policy. The company wants to block harmful prompts before model invocations, filter streamed model outputs in real time, and route flagged cases for human review. Which solution will meet these requirements?
Community Insight
The question tests full-lifecycle guardrail enforcement (pre-check, in-stream filter, post-check, routing, and IAM backstop); the trap is choosing an option that drops the pre-inference block or substitutes soft process controls for hard enforcement.
Amazon Bedrock Guardrails can be applied before, during, and after inference so a social messaging assistant blocks harmful prompts, filters streamed tokens in real time, and escalates flagged traffic for human review. This page confirms that a Step Functions workflow using ApplyGuardrail pre- and post-checks, InvokeModelWithResponseStream with the guardrail attached, an SQS review queue, and a bedrock:GuardrailIdentifier IAM condition is the only option meeting every stated requirement.
Option C is the most tempting wrong choice because it correctly uses InvokeModelWithResponseStream with the guardrail and a Lambda post-check, but it explicitly performs no pre-inference check, violating the requirement to block harmful prompts before model invocations.
Community Discussion (1 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
Option A is the only choice that satisfies all four requirements simultaneously: a Lambda step calls the ApplyGuardrail API to reject harmful prompts before any model token is generated, the InvokeModelWithResponseStream step attaches the guardrail so streamed output is filtered as it is produced, and a second Lambda step runs ApplyGuardrail against the response for post-checking. Flagged items are handed to an Amazon SQS queue, which is the standard mechanism for routing cases to a human review workflow. Finally, the bedrock:GuardrailIdentifier IAM condition key makes guardrail attachment mandatory at the API call level, so no developer can bypass the approved safety policy. That combination guarantees that every inference, not just most inferences, complies.Why the Other Options Are Wrong
Option B calls ApplyGuardrail before inference but then uses InvokeModel without streaming, which fails the explicit requirement to filter streamed model outputs in real time, and it delegates token suppression to the client UI where a user can simply inspect the raw response. Option C drops the pre-inference step entirely, so a harmful prompt still consumes model resources and is only caught after generation, directly contradicting the 'block harmful prompts before model invocations' requirement. Option D includes the right API sequence but relies on code reviews and other process controls instead of IAM enforcement, leaving compliance dependent on human discipline rather than a technical guarantee for every call.Community Comment Notes
As TNT87 noted, option A's pre-check validation with Lambda and the ApplyGuardrail API 'ensures that harmful prompts are blocked immediately before consuming unnecessary model generation resources.' That reasoning matches the exam's emphasis on blocking before invocation, and the same comment's endorsement of answer A aligns with this analysis.Official Reference
Exam Strategy
Read the requirement list first and tick off each clause against the option — streaming, pre-inference blocking, human routing, and enforcement each eliminate a specific distractor. IAM condition keys are the exam's tell for 'guaranteed compliance'; whenever an option offers only code reviews or client-side handling, treat it as a control gap.
Frequently Asked Questions
Why is skipping the pre-inference ApplyGuardrail check wrong here?
The question requires blocking harmful prompts before model invocations; option C skips that step, so unsafe inputs still reach and consume the foundation model.
Why does an IAM condition key matter for Bedrock guardrails?
A bedrock:GuardrailIdentifier IAM condition makes it impossible to invoke a model without a guardrail, so every inference is guaranteed to comply with the approved policy.
Related Analysis
Practice All AIP-C01 Questions
Access 110 questions with complete answers and detailed explanations.
View Full AIP-C01 Practice Test →