- Newest
- Most votes
- Most comments
To implement user confirmation for your Bedrock agent before invoking an action group, you have a couple of options:
-
Example implementations: While there aren't specific example implementations provided in the documentation, the general approach is to use the
requireConfirmationfield when defining your function schema, or thex-requireConfirmationfield for API schema definition when creating a new action. This enables the built-in functionality for user confirmation requests in Amazon Bedrock Agents. -
Agent-generated confirmation messages: Yes, you can have the agent generate a confirmation message without exposing function details. Here's how you can approach this:
a) In your agent's instructions, explicitly state that the agent should ask for user confirmation before running certain functions, especially those that modify data or perform sensitive operations.
b) Instruct the agent to use natural language when asking for confirmation, focusing on the actions being executed rather than providing the function name itself.
For example, you could include an instruction like this in your agent's prompt:
"Before creating, editing or deleting any records, ask for user confirmation for your actions. Include sufficient information in that ask to be clear about the action that will be taken. DO NOT provide the function name itself but rather focus on the actions being executed using natural language."
This approach allows the agent to generate a confirmation message that is clear and user-friendly without exposing the underlying function details.
By combining the built-in user confirmation feature with well-crafted instructions for your agent, you can create a robust confirmation mechanism that enhances the security and reliability of your Bedrock agent, particularly when it's operating in production environments.
Remember, when the user confirmation is enabled, the agent will return the confirmation configuration in the invocationInputs field of the InvokeAgent response. The user is then presented with options to confirm or deny the action. This helps prevent accidental or unauthorized actions and provides an additional layer of security against potential prompt injections.
Sources
Get user confirmation before invoking action group function - Amazon Bedrock
Best practices for building robust generative AI applications with Amazon Bedrock Agents – Part 2 | AWS Machine Learning Blog
answered 2 years ago
As the bot said, a common starting approach may be to include instructions in your agents' prompts to confirm with the user before invoking any actions. However, there are a couple of ways to reliably intercept any action calls before they're made, and insert application logic first:
- (sample notebook) Bedrock actually has an explicit user confirmation configuration on the actions, which I'd suggest to try out.
- (sample notebook) Alternatively, look at return of control. In this pattern the service doesn't actually call the actions on your behalf, but tells your application code when the agent has determined to make a tool call. You can then make the decision whether you call the tool directly, or show some kind of confirmation first (or whatever other intermediate logic you need).
- That same repository actually has an example combining RoC and user confirmation, too
Your second ask to "generate a confirmation message for the user without exposing details of the underlying function" sounds a bit domain-specific to me: Of course you'll need to expose some information for the user to make an informed choice ("I'm about to call an API is that okay" seems too vague to be useful as informed consent by the user) - but I can appreciate why you might not want to fully expose the API structure... It sounds to me like that might be a use-case for a separate LLM call (maybe using pattern 2 return of control?) with an engineered prompt template to strike the right balance of disclosure for your particular scenario.
Relevant content
- AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated 5 months ago
