Skip to content

Dynamic Guardrails Per Session in Amazon Bedrock Agents

0

I'm working on a SaaS product using Amazon Bedrock agents, and we have multiple customers, each with their own preferences for AI behavior and content moderation. Right now, it seems that an agent can only have one guardrail, set at creation or update.

Since different customers have different moderation needs, creating a separate agent per customer isn’t scalable. Is there a way to apply different guardrails dynamically per session instead of per agent?

Any best practices or workarounds for handling this in a multi-tenant setup?

Thanks! Maor

2 Answers
0
Accepted Answer

Unfortunately, Amazon Bedrock does not currently support applying different guardrails dynamically per session for a single agent. You are correct that an agent can only have one guardrail configuration, which is set when the agent is created or updated.

However, there are a few potential approaches you could consider to address your multi-tenant scenario with different moderation needs:

  1. Use the ApplyGuardrail API: Instead of relying solely on agent-level guardrails, you could implement custom logic in your application to use the ApplyGuardrail API. This API allows you to assess text using pre-configured guardrails without invoking foundation models directly. You could maintain different guardrail configurations for each customer and apply the appropriate one before sending requests to the agent.

  2. Implement custom filtering logic: You could create a more generalized guardrail configuration for the agent, and then implement additional custom filtering logic in your application layer. This would allow you to apply customer-specific rules or content moderation on top of the base guardrail.

  3. Use multiple knowledge bases: If your use case allows, you could potentially use different knowledge bases for different customers, each with its own set of rules or content. This could provide some level of customization without needing multiple agents.

  4. Leverage prompt engineering: You could potentially include customer-specific instructions or rules as part of the prompt sent to the agent. While this wouldn't replace guardrails, it could help tailor the agent's behavior for different customers.

While these approaches may not fully replicate the functionality of per-session guardrails, they could help you achieve a more customized experience for your different customers within the current limitations of Amazon Bedrock Agents.

It's worth noting that Amazon Web Services frequently updates and expands its offerings. You may want to keep an eye on future updates to Amazon Bedrock, as more flexible guardrail configurations could potentially be introduced in the future.

Sources
Use the ApplyGuardrail API in your application - Amazon Bedrock
How Amazon Bedrock Guardrails works - Amazon Bedrock
Use guardrails for your use case - Amazon Bedrock

answered 2 years ago

AWS
EXPERT

reviewed 2 years ago

  • Agree that the ApplyGuardrail API, in particular, is probably where I'd suggest to start. Rather than pushing the target guardrail within the Agent definition, you can have your application (in AWS Lambda? Something else?) call ApplyGuardrail on the user input before triggering the agent, and the agent response before returning it to the user.

0

Hello Maor,

Thank you for using AWS Bedrock !!

From the description, I see that you reached out to find a solution for implementing customer-specific AI behavior and content moderation in a multi-tenant SaaS product built with Amazon Bedrock agents. The challenge is that Bedrock agents currently only support one guardrail configuration per agent, which must be set during creation or updates. Creating individual agents for each customer's unique moderation requirements isn't a scalable approach, and you're seeking guidance on whether dynamic per-session guardrails are possible or if there are alternative solutions for managing different customer preferences in a multi-tenant environment.

I would like to inform you that Amazon Bedrock doesn't currently support dynamic guardrail configuration per session, I can suggest several approaches to address your multi-tenant scenario:

  1. Utilize the ApplyGuardrail API [1]:
  • Implement custom logic to maintain different guardrail configurations per customer
  • Use the ApplyGuardrail API to evaluate content before sending it to the agent
  • This provides an additional layer of content moderation specific to each customer
  • Store customer-specific guardrail configurations in a database for easy management
  1. Implement Prompt Engineering:
  • Include customer-specific instructions within the prompt template [2]
  • Add specific moderation rules and behavioral guidelines in the system prompt
  • Use knowledge bases to store customer-specific preferences and rules [3]

In case you again face any issue, Please reach out to us via a support case with all the relevant details as your use-case might need a deeper investigation.

References: [1] Amazon Bedrock ApplyGuardrail API Documentation: https://docs.aws.amazon.com/bedrock/latest/APIReference/API_ApplyGuardrail.html  [2] Amazon Bedrock Prompt Engineering Best Practices: https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-engineering.html  [3] Amazon Bedrock Agents Developer Guide: https://docs.aws.amazon.com/bedrock/latest/userguide/agents.html

AWS

answered 2 years 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.