Skip to content

How to associate an agent with a guardrail

0

Hi, I don't see anything in the agent builder interface that allows guardrail specification. How do I link a guardrail to an agent. I also looked in the InvokeAgentCommand api and there is no param to specify the guardrail for the agent. Anyone knows how these two are supposed to be associated? I have a functioning agent and created a guardrail and a version for it. How do I now deploy this guardrail?

asked a year ago637 views

1 Answer
0

You can associate a guardrail with your Amazon Bedrock agent either when creating a new agent or when updating an existing one.

In the Amazon Bedrock console:

  1. Navigate to the Agent builder
  2. In the "Guardrail details" section, choose "Edit"
  3. Select your guardrail from the dropdown menu under "Select guardrail"
  4. Choose the version you want to use under "Guardrail version"
  5. You can select "View" to review your Guardrail settings
  6. Save your changes

Using the API, you can associate a guardrail by:

  1. Including a guardrailConfiguration field in the body of a CreateAgent or UpdateAgent request
  2. The configuration should specify the guardrail identifier and version

Here's an example of how to associate a guardrail with an agent using the API:

gconfig = { 
"guardrailIdentifier": 'your-guardrail-id',
"guardrailVersion": 'DRAFT'
}

response = bedrock_agent_client.create_agent(
agentName=agent_name,
agentResourceRoleArn=agent_role['Role']['Arn'],
foundationModel="your-chosen-model",
instruction=agent_instruction,
guardrailConfiguration=gconfig,
)

Important: If you associate a guardrail with your agent, you must also attach an identity-based policy to the agent's service role that includes permissions for the bedrock:ApplyGuardrail action with the appropriate guardrail resource.
Sources
Implement safeguards for your application by associating a guardrail with your agent - Amazon Bedrock
Use guardrails for your use case - Amazon Bedrock
Improve LLM application robustness with Amazon Bedrock Guardrails and Amazon Bedrock Agents | AWS Machine Learning Blog
Create and configure agent manually - Amazon Bedrock
Create a service role for Amazon Bedrock Agents - Amazon Bedrock

answered a year ago

  • I can't find the 'guardrail details' section in agent builder. Am i missing something?

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.