- Newest
- Most votes
- Most comments
To address your need for passing authentication context to Bedrock agents when calling functions, there are a few approaches you can consider:
-
Session Attributes: You can pass the authentication token through the SessionState object when invoking the agent. Specifically, you can include the token in the sessionAttributes field. This allows you to maintain the auth context across multiple turns of conversation without exposing it directly in the agent's prompt.
-
Lambda Function Handling: In your action group Lambda function, you can retrieve the authentication header from the event object. This allows you to use the token to verify the user's access for specific actions using a service like Amazon Verified Permissions.
-
Return of Control: You can use the "return of control" pattern, where the agent doesn't directly call the actions but instead notifies your application code when it determines a tool call is needed. This gives you the opportunity to implement your own authorization logic before executing the action.
As for limiting which tools are available to a given agent based on the user, you have a couple of options:
-
Dynamic Tool Selection: You can implement logic in your Lambda function to dynamically select which tools to make available based on the user's permissions. This would involve checking the user's authorization before allowing certain tool calls.
-
Layered Authorization: Implement a layered authorization approach where you use Amazon Verified Permissions to check if a user is authorized for a specific action before the agent executes it. This allows you to have fine-grained control over which actions a user can perform, effectively limiting the available tools based on their permissions.
-
Multiple Agents: Create different agents with varying sets of tools and route users to the appropriate agent based on their authorization level.
Remember to always follow security best practices, such as using strong authentication (e.g., OpenID Connect with MFA) and implementing proper threat modeling for your application. These approaches allow you to maintain security while providing a personalized experience for different user roles within your company.
Sources
Design secure generative AI application workflows with Amazon Verified Permissions and Amazon Bedrock Agents | AWS Machine Learning Blog
Bedrock Get user confirmation before invoking action group | AWS re:Post
Control agent session context - Amazon Bedrock
Enhancing data privacy with layered authorization for Amazon Bedrock Agents | AWS Security Blog
Relevant content
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 7 months ago
