I am building a service based on AWS Bedrock and I have run into an issue which I have been unable to solve. In short, I want to return the return value of an action in addition to the default text response.
For example, imagine that there is an action which searches for books in a database. I would like to be able to prompt the agent to perform a search and return the result and a text response, something like:
{
message: "I some books which you might enjoy",
bookIds: [1, 2, 3]
}
I could then use the ids for things such as displaying the covers to the user (in reality I have a more complicated use-case but this gets at the problem).
My current architecture is as follows: The back-end receives a prompt and calls InvokeAgent -> agent invokes an action group and receives a response (for example a list of bookIds) -> The agent uses this to generate a natural language response and returns it to the back-end.
Basically, the issue I am having is that I have been unable to find a good way to programatically read the return value from an action group.
What I have tried thus far:
- Reading tons of aws docs
- I tried implementing a custom parser for the orchestration, but was unable to find a way to reliably see the response in the messages passed between the different steps. Most of the time the response data appears in the text field but in my experience this is not a 100% reliable.
- I found a work around which involves enabling traces for the agent and reading the debug messages, but I am not entirely satisfied with this since 1) It results in at least 10x the amount of data sent 2) It seems kind of hacky since that is not the intended use case for the traces.
If anyone who is more experienced in Bedrock has any input or advice it would be greatly appreciated! :)
I