Add support for AWS Bedrock Guardrails (guardrailIdentifier / guardrailVersion) for the Bedrock provider
Summary
Add support for attaching an AWS Bedrock Guardrail to requests made by the AWS Bedrock provider. Today the Bedrock provider invokes models directly with no way to specify a guardrail, so it's not possible to apply content filtering, denied topics, or prompt-attack protection to the prompts and model responses handled by this plugin.
Motivation / Use case
Supporting AWS Bedrock guardrails natively allows users of this provider to adopt the plugin without weakening their security posture.
Proposed solution
Add optional configuration fields to the Bedrock provider:
guardrailIdentifier— the guardrail ID or ARNguardrailVersion— the guardrail version (e.g.,DRAFTor a numeric version)guardrailTrace(optional) — enable/disable trace output (enabled/disabled)
When the fields are set, the provider should pass them on the request; when empty, behavior is unchanged (fully backward compatible).
Example configuration
UI (Manage Jenkins → Configure System): new optional "Guardrail Identifier" and "Guardrail Version" fields under the AWS Bedrock provider.
Configuration as Code (CasC):
unclassified:
explainError:
aiProvider:
bedrock:
model: "anthropic.claude-3-5-sonnet-20240620-v1:0"
region: "us-east-1"
guardrailIdentifier: "arn:aws:bedrock:us-east-1:123456789012:guardrail/abc123"
guardrailVersion: "1"
# guardrailTrace: "enabled" # Optional
enableExplanation: true
Expected behavior
- If
guardrailIdentifieris set, the plugin attaches the guardrail to every Bedrock request it makes. - If the guardrail blocks the input or output, the plugin surfaces the guardrail's intervention message gracefully in the build sidebar instead of failing with an unhandled error.
- If the fields are empty, requests behave exactly as they do today.
Additional context
- AWS SDK reference:
ConverseRequest.guardrailConfig(GuardrailConfiguration)andInvokeModelRequestguardrail headers. - Docs: Include a guardrail with the Converse API
I'm happy to help test against a real guardrail configuration and provide feedback.
Hi @orasul thanks for raising the issue. Could you please try this build https://repo.jenkins-ci.org/incrementals/io/jenkins/plugins/explain-error/205.v2ca_817a_8150a_/ to see if it solves your issue?