Bedrock agent invokation does not return "returnControl" element

0

All, in my Python call i am trying to invoke my agent. Agent is instructed to call a specific function for certain condition. Call Is: agent = BedrockAgent(agentAliasId='...',agentId='...') response = agent.invokeWithFunction( enableTrace=True, endSession=False, prompt='provede...', ) in a console agent asks for specific function information. in Python, trace is also indicates that function should be invilved. The problem is that is i do not see returnControl element in response. Agent and Agent alias are verified and action is "return control" in a console definition. Any help would be appreciated Thank you Yevgeniy

YK
asked 24 days ago288 views
3 Answers
1
Accepted Answer

That was a bug in boto3. Latest version - 1.34.111 - works

YK
answered 24 days ago
profile picture
EXPERT
reviewed 24 days ago
0

Hello.

If you execute invoke_agent() as is, the response will include "returnControl".
Have you tried running invoke_agent()?
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock-agent-runtime/client/invoke_agent.html

profile picture
EXPERT
answered 24 days ago
0

yes, and it does not return "returnControl".

class BedrockAgent: def init(self, agentId = "..", agentAliasId= "", name = "bedrock-agent-runtime", verify = False): self.agentId = agentId self.agentAliasId = agentAliasId self.client = boto3.client(name, verify=verify)

def invokeWithFunction(self, prompt, enableTrace=False, endSession=True, sessionId=str(uuid.uuid4())): response = self.client.invoke_agent( agentAliasId= self.agentAliasId, agentId=self.agentId, enableTrace=enableTrace, endSession=endSession, inputText=prompt, sessionId=sessionId) return response


agent = BedrockAgent(agentAliasId='...',agentId='...') response = agent.invokeWithFunction( enableTrace=True, endSession=False, prompt='please find ...', ) completion = response.get("completion") if completion: for event in completion: print("----------- Event -----------------") print(event)

Thank you, YK

YK
answered 24 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions