BedRock Agent ignoring lambda provided to answer questions

0

I try to configure a BedRock Agent to invoke a lambda function and use the returned data to generate the answer to the user.

But unfortunatelly while testing the Agent, in the "Step 0 / Trace" the Agent said "...I know only the action user::askUser..."

My Agent configuration steps:

  1. defined a new Agent with an Action Group to call a labda function
  2. provided the target lambda function
  3. provided openapi3 spec docs exported from ApiGateway
  4. provided instructions to define the Agent
  5. provided the lambda function description and purpose to the Agent
profile picture
Fabio
質問済み 5ヶ月前283ビュー
2回答
0

Hi Fabio,

It seems like the Bedrock agent is unable to invoke your Lambda function due to missing permissions.

To allow the Bedrock agent to invoke the Lambda function, you need to add a permission to the Lambda function's resource-based policy. Specifically, you need to grant the lambda:InvokeFunction permission to the Bedrock agent IAM role.

Go to the configuration section of the lambda function -> Permissions -> Resource-based policy statements

You can check the resource-based policy on the Lambda function and add a statement like:

{ "Sid": "AllowBedrockAgentInvocation",

"Effect": "Allow",

"Principal": {"Service": "bedrock.amazonaws.com"},

"Action": "lambda:InvokeFunction",

"Resource": "arn:aws:lambda:region:account-id:function:function-name"

}

This will allow the Bedrock agent to invoke the Lambda function. Please replace the Resource with the Arn of the bedrock agent.

Let me know if this helps.

AWS
回答済み 1ヶ月前
profile picture
エキスパート
レビュー済み 1ヶ月前
0

To configure a Bedrock Agent to invoke a Lambda function and use the returned data to generate the answer:

Define an Action Group in the agent configuration that targets the Lambda function.

Provide the OpenAPI 3.0 spec for the API Gateway endpoint used by the Lambda function.

In the prompt template configuration for the agent, enable the use of a Lambda function for parsing and select the function defined in the Action Group.

Attach permissions to allow the agent to invoke the Lambda function. For example, using an IAM role with a policy allowing lambda:InvokeFunction .

Test the agent and check the trace to verify the Lambda function is being called and the response parsed correctly. You may need to debug the Lambda function or parsing logic if errors occur.

https://docs.aws.amazon.com/bedrock/latest/userguide/advanced-prompts-configure.html

profile picture
エキスパート
回答済み 1ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ