Skip to content

feat(react-ai): Add Amazon Bedrock Guardrails support to AIConversation#6972

Open
altf4-games wants to merge 2 commits into
aws-amplify:mainfrom
altf4-games:feat/ai-conversation-guardrails
Open

feat(react-ai): Add Amazon Bedrock Guardrails support to AIConversation#6972
altf4-games wants to merge 2 commits into
aws-amplify:mainfrom
altf4-games:feat/ai-conversation-guardrails

Conversation

@altf4-games
Copy link
Copy Markdown

Description of changes

Resolves #6432

Adds Amazon Bedrock Guardrails support to the AIConversation component and createAIConversation factory in the @aws-amplify/ui-react-ai package.

Guardrails enforce safety policies (content filtering, denied topics, sensitive information redaction, etc.) on AI model responses via the Bedrock Converse API. This was previously unavailable in the UI kit despite the underlying API supporting it natively.

Usage:

// Via factory
const { AIConversation } = createAIConversation({
  guardrails: {
    guardrailIdentifier: 'abc123xyz',  // from AWS Bedrock console
    guardrailVersion: '1',             // or 'DRAFT'
    trace: 'enabled',                  // optional
  },
});

// Or directly on the component
<AIConversation
  guardrails={{ guardrailIdentifier: 'abc123xyz', guardrailVersion: '1' }}
  messages={messages}
  handleSendMessage={handleSendMessage}
/>

Implementation notes:

  • Guardrails are conversation-level (not per-message), consistent with allowAttachments and responseComponents
  • Follows the same pattern as the existing AIContextContext / toolConfiguration feature
  • New GuardrailConfiguration type is publicly exported from @aws-amplify/ui-react-ai
  • @aws-amplify/data-schema's ConversationSendMessageInputObject does not yet include guardrailConfiguration — a type cast is used internally (safe since Bedrock already supports the field natively). A companion issue in aws-amplify/amplify-data should add the upstream type so the cast can be removed.

Issue #, if available

Closes #6432

Description of how you validated changes

  • Added 4 new unit tests for GuardrailsContext (default value, config passthrough, trace mode, undefined passthrough)
  • Added 2 new unit tests in FormControl.spec.tsx (message sent without guardrails, message sent with guardrails)

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@altf4-games altf4-games requested a review from a team as a code owner May 1, 2026 06:37
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 1, 2026

🦋 Changeset detected

Latest commit: 0bf1cad

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@aws-amplify/ui-react-ai Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Amazon Bedrock Guardrail Support

1 participant