Return control to the agent developer by sending elicited information in an InvokeAgent response
Rather than sending the information that your agent has elicited from the user to a Lambda function for fulfillment, you can instead choose to return control to the agent developer by sending the information in the InvokeAgent response. You can configure return of control to the agent developer when creating or updating an action group. Through the API, you specify RETURN_CONTROL
as the customControl
value in the actionGroupExecutor
object in a CreateAgentActionGroup or UpdateAgentActionGroup request. For more information, see Add an action group to your agent in Amazon Bedrock.
If you configure return of control for an action group, and if the agent determines that it should call an action in this action group, the API or function details elicited from the user will be returned in the invocationInputs
field in the InvokeAgent response, alongside a unique invocationId
. You can then do the following:
-
Set up your application to invoke the API or function that you defined, provided the information returned in the
invocationInputs
. -
Send the results from your application's invocation in another InvokeAgent request, in the
sessionState
field, to provide context to the agent. You must use the sameinvocationId
andactionGroup
that were returned in the InvokeAgent response. This information can be used as context for further orchestration, sent to post-processing for the agent to format a response, or used directly in the agent's response to the user.Note
If you include
returnControlInvocationResults
in thesessionState
field, theinputText
field will be ignored.
To learn how to configure return of control to the agent developer while creating the action group, see Add an action group to your agent in Amazon Bedrock.
Example for returning control to the agent developer
For example, you might have the following action groups:
-
A
PlanTrip
action group with asuggestActivities
action that helps your users find activities to do during a trip. Thedescription
for this action saysThis action suggests activities based on retrieved weather information
. -
A
WeatherAPIs
action group with agetWeather
action that helps your user get the weather for a specific location. The action's required parameters arelocation
anddate
. The action group is configured to return control to the agent developer.
The following is a hypothetical sequence that might occur:
-
The user prompts your agent with the following query:
What should I do today?
This query is sent in theinputText
field of an InvokeAgent request. -
Your agent recognizes that the
suggestActivities
action should be invoked, but given the description, predicts that it should first invoke thegetWeather
action as context for helping to fulfill thesuggestActivities
action. -
The agent knows that the current
date
is2024-09-15
, but needs thelocation
of the user as a required parameter to get the weather. It reprompts the user with the question "Where are you located?" -
The user responds
Seattle
. -
The agent returns the parameters for
getWeather
in the following InvokeAgent response (select a tab to see examples for an action group defined with that method): -
Your application is configured to use these parameters to get the weather for
seattle
for the date2024-09-15
. The weather is determined to be rainy. -
You send these results in the
sessionState
field of another InvokeAgent request, using the sameinvocationId
,actionGroup
, andfunction
as the previous response. Select a tab to see examples for an action group defined with that method: -
The agent predicts that it should call the
suggestActivities
action. It uses the context that it's rainy that day and suggests indoor, rather than outdoor, activities for the user in the response.