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!

2개 답변
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.

답변함 4달 전
-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
답변함 4달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠