最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Bedrock agent cannot correctly parse response from Node lambda - Stack Overflow

programmeradmin0浏览0评论

I have a Bedrock agent with an action group connected to a lambda, and defined with an API schema. Despite ensuring that my lambda response matches the schema from the documentation (.html#agents-lambda-response), I still see the following error when the agent attempts to call my endpoint:

ERROR DependencyFailedException: The server encountered an error processing the Lambda response. Check the Lambda response and retry the request

This is what the lambda returns:

{
    "messageVersion": "1.0",
    "response": {
        "actionGroup": "downstream-actions",
        "apiPath": "/hello",
        "httpMethod": "GET",
        "httpStatusCode": 200,
        "responseBody": {
            "application/json": {
                "body": "{\"message\":\"Hello, world!\"}"
            }
        }
    }
}

The lambda is Node. I have tried stringifying the entire object before returning it as well to the same result. Am I missing something?

Edit: including api schema:

{
  openapi: '3.0.0',
  info: {
    title: 'Downstream Action API',
    version: '1.0.0',
    description: 'API for invoking downstream actions',
  },
  paths: {
    '/hello': {
      get: {
        summary: 'Get a hello world message',
        description: 'Simple endpoint that returns a hello world message',
        operationId: 'getHello',
        responses: {
          '200': {
            description: 'Successful response',
            content: {
              'application/json': {
                schema: {
                  type: 'object',
                  properties: {
                    message: {
                      type: 'string',
                    },
                  },
                },
              },
            },
          },
        },
      },
    },
  },
}

I have a Bedrock agent with an action group connected to a lambda, and defined with an API schema. Despite ensuring that my lambda response matches the schema from the documentation (https://docs.aws.amazon.com/bedrock/latest/userguide/agents-lambda.html#agents-lambda-response), I still see the following error when the agent attempts to call my endpoint:

ERROR DependencyFailedException: The server encountered an error processing the Lambda response. Check the Lambda response and retry the request

This is what the lambda returns:

{
    "messageVersion": "1.0",
    "response": {
        "actionGroup": "downstream-actions",
        "apiPath": "/hello",
        "httpMethod": "GET",
        "httpStatusCode": 200,
        "responseBody": {
            "application/json": {
                "body": "{\"message\":\"Hello, world!\"}"
            }
        }
    }
}

The lambda is Node. I have tried stringifying the entire object before returning it as well to the same result. Am I missing something?

Edit: including api schema:

{
  openapi: '3.0.0',
  info: {
    title: 'Downstream Action API',
    version: '1.0.0',
    description: 'API for invoking downstream actions',
  },
  paths: {
    '/hello': {
      get: {
        summary: 'Get a hello world message',
        description: 'Simple endpoint that returns a hello world message',
        operationId: 'getHello',
        responses: {
          '200': {
            description: 'Successful response',
            content: {
              'application/json': {
                schema: {
                  type: 'object',
                  properties: {
                    message: {
                      type: 'string',
                    },
                  },
                },
              },
            },
          },
        },
      },
    },
  },
}
Share Improve this question edited 2 days ago Haskell asked Feb 5 at 17:37 HaskellHaskell 3773 gold badges7 silver badges15 bronze badges 2
  • hard to say without also seeing your API schema – emma ray Commented Feb 9 at 4:44
  • @emmaray updated to include – Haskell Commented 2 days ago
Add a comment  | 

1 Answer 1

Reset to default 0

If anyone stumbles upon this question, I got it to work by setting architecture: lambda.Architecture.ARM_64 on my agent-invoked lambda.

发布评论

评论列表(0)

  1. 暂无评论