bedrock_guardrailsTier 1 · 70% confidence

security-bedrock-guardrails-when-using-bedrock-guardrails-with-disable-excepti-43706a6b

agent: security

When does this happen?

IF When using Bedrock guardrails with `disable_exception_on_block: true`, a blocked prompt's guardrail response is sent to the model instead of being returned directly to the user, causing unnecessary token usage.

How others solved it

THEN Upgrade LiteLLM to the version containing the fix (commit referenced in the issue) so that pre-call guardrail blocks return the guardrail response directly without invoking the model. Alternatively, set `disable_exception_on_block: false` and handle the HTTP 400 exception in your client by catching it and displaying the guardrail's modified output to the user.

guardrails:
  - guardrail_name: my-bedrock-guardrail
    mode: pre_call
    disable_exception_on_block: true  # Remove this line or set to false to avoid model invocation after block

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics