AWS Bedrock Agent error - 'failureReason': 'LLM prediction format incorrect'

1

Hi, I have created an agent and it always works fine when tested with aws console. However, when trigger agent from code(lambda function with python), providing agent and alias id, it works as expected sometimes and fails quite a lot of times as well with below error -

trace': {'agentId': 'SJ4AHHVXX', 'agentAliasId': 'SZD0OGXXX', 'sessionId': 'SESSMAINT1', 'trace': {'failureTrace': {'traceId': 'd34fe4ba-78b6-4ccf-8aa5-682e74890d31-0', 'failureReason': 'LLM prediction format incorrect'}}}} {'chunk': {'bytes': b'Sorry, I am unable to assist you with this request.'}}

sample code -

def invoke_maintenance_agent(searchterm): try: response = bedrock.invoke_agent( agentId='SJ4AHHVXX', agentAliasId='SZD0OGXXX', sessionId='SESSMAINT1', inputText=''.join(searchterm) ) completion = response.get('completion') if completion: print('inside completion') all_records=[] for event in completion: # loop over to get each record print(event) if 'chunk' in event: chunk = event.get('chunk') bytes = chunk.get('bytes') all_records.append(bytes) agentResponse = str(all_records[0],'utf-8') else: agentResponse = 'Some issue in invoking agent' return agentResponse else: return 'Maintenance Agent response is incorrect' except Exception as e: raise RuntimeError(f"Exception - {str(e)}") return 'empty'

THis exact code works well quite a lot of times. Not sure what the problem is. Can someone please assist? Thanks a lot!

asked 3 months ago630 views
2 Answers
0

I was able to solve this error couple of days back. It actually meant that I was not able to trigger the underlying lambda in the agent. Reason, I suppose is due to some session mgmt issues. Managing the session id fixed this issue.

answered 3 months ago
-1

Hello,

The above error happens when the format of the model prediction could not be be parsed. The agent responds back with a final answer that it cannot respond to the user request, while the failure reason comes in trace.

We may need to get access to your agent schema and other code. So, to perform specific investigation into your issue and recommendations for next steps i request you to reach out to AWS Support [1] (Bedrock) along with your issue or use case in detail, and we would be happy to assist you further.

References: [1] Creating support cases and case management - https://docs.aws.amazon.com/awssupport/latest/user/case-management.html#creating-a-support-case

AWS
answered 3 months 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