Bedrock Agent Runtime - InvokeAgentCommand documentation missing for Multi-agent collaboration
Describe the issue
The InvokeAgentCommand documentation & Example Syntax is missing the required configuration/parameters for Multi-agent collaboration scenario. With ReturnControl feature, the Agent (without collaboration) is working as expected, but the Agent in Supervisor mode is throwing below error:
ValidationException: Validation failed: Unexpected actionGroup: action-group-XXXX or function : get_XXXX_data encountered for invocationId: f8b89c79-19b7-4b1d-ab08-bdfc3bde284d
So I looked at the InvokeAgentResponse in the Example Syntax, added the agentCollaboratorName parameter. Now it just calls the same ReturnControl function in a loop.
Links
https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/bedrock-agent-runtime/command/InvokeAgentCommand/
Hi @PavaniKa - thanks for reaching out.
According to the error, it seems like the action-group being used for multi-agent is invalid. Can you share the steps you followed along with your code snippet for further guidance?
You can also follow this service docs for working with multi-agent collaboration: https://docs.aws.amazon.com/bedrock/latest/userguide/create-multi-agent-collaboration.html
Best, John
Sure. Here is the scenario. I have two agents Agent1, Agent2. Both have Action Groups with invocation set as Return control. Both are working as expected (with the code below) from my node.js app.
I created a new SuperAgent, enabled Multi-Agent Collaboration in it & configured Agent1, Agent2 as collaborators. When invoked, control is returned as expected and corresponding function is called. Below Error is thrown when the final response is sent back:
ValidationException: Validation failed: Unexpected actionGroup: action-group-XXXX or function : get_XXXX_data encountered for invocationId: f8b89c79-19b7-4b1d-ab08-bdfc3bde284d
Please note, these are valid actionGroup, function combination in one of the collaborator agent(s).
Here is the code block. Only difference between SuperAgent and normal agent invocations is the BEDROCK_AGENT_ID, BEDROCK_AGENT_ALIAS_ID values.
const BEDROCK_AGENT_ID = process.env.BEDROCK_AGENT_ID;
const BEDROCK_AGENT_ALIAS_ID = process.env.BEDROCK_AGENT_ALIAS_ID;
async function __invokeBedrockAgent(agentPayload, returnControlData, apiResponse) {
const bedrockClient = agentPayload.client;
const invocationId = returnControlData.invocationId;
const functionInvocationInput = returnControlData.invocationInputs[0].functionInvocationInput;
const actionGroup = functionInvocationInput.actionGroup;
const functionName = functionInvocationInput.function;
const responseBody = {
TEXT: {
body: JSON.stringify(apiResponse), //JSON response from API
}
};
const inputPayload = {
agentId: BEDROCK_AGENT_ID, //required
agentAliasId: BEDROCK_AGENT_ALIAS_ID, //required
sessionId: agentPayload.sessionId, //required
endSession: false, //this will make sure the Agent remembers the state
inputText: agentPayload.inputText, // this will be ignored if there is a session state
sessionState: {
invocationId: invocationId, //required
returnControlInvocationResults: [
{
functionResult: {
actionGroup: actionGroup,
function: functionName,
responseBody: responseBody,
responseState: 'REPROMPT', //this can be 'REPROMPT' or 'COMPLETED' or 'FAILED'
},
},
],
}
};
try {
console.log(">>> Bedrock Agent Input Payload: ", inputPayload);
const command = new InvokeAgentCommand(inputPayload);
let completion = "";
//send the command
console.log(">>> Sending Command to Bedrock Agent...");
const response = await bedrockClient.send(command);
if (response.completion === undefined) {
throw new Error("Completion is undefined");
}
//process the response
const readable = response.completion;
for await (const event of readable) {
console.log(">>> Processing Event...");
completion = await processEvent(event, agentPayload);
}
return completion;
} catch (err) {
console.error(err, err.stack);
throw new Error(err.stack);
}
};
Thanks for sharing your use case. I reached out to service team, on your behalf, to review it and provide guidance (ref: P192976310). I'll update here when I hear back.
Here's response from service and request for verification:
with MulitAgent collaboration using ROC, can customer check if they are providing the correct
agentIdin theReturnControlInvocationResultpayloads? Each ROCInvocationInputpayload has aagentIdthat is required for bedrockAgents to route request to the correct agent in multi-agent set-up.
Reference boto3 payload
This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.
Thanks for the update.
Doesn't that defeat the purpose of a 'Supervisor' Agent If we are controlling the route by including agentId of a Collaborator Agent in the InvocationInput payload?
@aBurmeseDev Considering the above case , can i get the respective outputs from agent 1 and agent 2 individually from the super agent If we use BEDROCK_AGENT_ID, BEDROCK_AGENT_ALIAS_ID values of superagent
Hey all - I'll have to relay your concerns back to service team and wait for their response. I'll keep it posted.
Thanks @aBurmeseDev will wait for you as the above question is critical for me. Please let this thread stay open until then
I had the same issue, adding the agentId to the functionInvocationInput fixed the problem @PavaniKa https://docs.aws.amazon.com/bedrock/latest/userguide/agents-returncontrol.html
Although I haven't heard back from service team, I was able to confirm the finding above. Let me know if you have any other questions @PavaniKa
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.