Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amazon Bedrock Agent support #2007

Open
1 of 2 tasks
martinsafsten opened this issue Mar 10, 2025 · 4 comments
Open
1 of 2 tasks

Amazon Bedrock Agent support #2007

martinsafsten opened this issue Mar 10, 2025 · 4 comments
Assignees
Labels
feature-request A feature should be added or improved. m Effort estimation: medium module/aspnetcore-support p2 This is a standard priority issue

Comments

@martinsafsten
Copy link

martinsafsten commented Mar 10, 2025

Describe the feature

Add support for receiving JSON requests from a Amazon Bedrock Agent, with a Action Group configured with an OpenAPI specification. The JSON structures between the HttpApi/RestApi via API Gateway are incompatible with the current setup.

Use Case

Creating a .NET Core Web API that can be used by a Amazon Bedrock Agent. The API can generate the Swagger/OpenAPI specification that can be uploaded to the Agent as is

Proposed Solution

The general idea is to add a new EventSource specifically for Bedrock Agents, that translates that format into a AspNetCore request. It should make the setup as seamless as for HttpApi and RestApi for the end user.

The end result should look something like this:

builder.Services.AddAWSLambdaHosting(LambdaEventSource.BedrockAgentApi)

Other Information

I created a Repost question detailing the issue: https://repost.aws/questions/QUXj8PAYBRQiKqd5VRWHNQfQ/amazon-lambda-aspnetcoreserver-hosting-as-bedrock-agent-action-group-lambda

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

AWS .NET SDK and/or Package version used

latest

Targeted .NET Platform

.NET 6, .NET 8

Operating System and version

any

@martinsafsten martinsafsten added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Mar 10, 2025
@ashishdhingra ashishdhingra self-assigned this Mar 10, 2025
@ashishdhingra ashishdhingra added needs-investigation and removed needs-triage This issue or PR still needs to be triaged. labels Mar 10, 2025
@ashishdhingra
Copy link
Contributor

@martinsafsten Good afternoon. Lambda input event from Amazon Bedrock specifies the structure of Lambda input event that is sent when an action group using a Lambda function is invoked. This appears to be a good candidate for event package for Bedrock (refer similar package https://github.com/aws/aws-lambda-dotnet/tree/master/Libraries/src/Amazon.Lambda.LexV2Events), which would implement custom POCO classes for input and response formats for Lambda function. Please review your request and confirm if this is the case. Thereafter, feel free to contribute PR to contribute the new events package

Thanks,
Ashish

@ashishdhingra ashishdhingra added p2 This is a standard priority issue m Effort estimation: medium response-requested Waiting on additional info and feedback. Will move to close soon in 7 days. and removed needs-investigation labels Mar 10, 2025
@martinsafsten
Copy link
Author

martinsafsten commented Mar 10, 2025

Hello Ashish! Thanks for looking into this.

I have worked on it for a few days, and I have a fork with an implementation, which includes a new event package with the bedrock request and response, and added support in Amazon.Lambda.AspNetCoreServer and Amazon.Lambda.AspNetCoreServer.Hosting for a new LambdaEventSource that would simplify the setup. I think I worked out most of the hard parts with the actual conversion and serialization.

Here is the commit: martinsafsten@ccadcef

@martinsafsten
Copy link
Author

If you want to keep the AspNetCoreServer packages free of this Bedrock specific code, maybe a refactoring to a separate library Amazon.Lambda.AspNetCoreServer.BedrockAgentApi.Hosting or something similar, with a reference to the core package, and its own Service extension AddAWSLambdaBedrockAgentApiHosting

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to close soon in 7 days. label Mar 11, 2025
@martinsafsten
Copy link
Author

I tried deploying a test lambda with the new code and used it in my test bedrock agent. Some tweaks required, which I updated in the commit above, but it looks good. Maybe a integration test is in order to validate and secure it?

Here is a excerpt from the trace in the agent:

"invocationInput": [
    {
      "actionGroupInvocationInput": {
        "actionGroupName": "agda-assistant",
        "apiPath": "/api/employees/search",
        "executionType": "LAMBDA",
        "parameters": [
          {
            "name": "term",
            "type": "string",
            "value": "John Smith"
          }
        ],
        "verb": "get"
      },
      "invocationType": "ACTION_GROUP",
      "traceId": "b11e80a3-d835-4baa-8619-d3fb1828424d-0"
    }
  ],
  "observation": [
    {
      "actionGroupInvocationOutput": {
        "text": "[{\"id\":1,\"name\":\"John Smith\",\"department\":\"Engineering\",\"position\":\"Senior Developer\",\"vacationDaysRemaining\":15,\"directReports\":[{\"id\":2,\"name\":\"Alice Johnson\",\"department\":\"Engineering\",\"position\":\"Developer\",\"vacationDaysRemaining\":12,\"directReports\":[]},{\"id\":3,\"name\":\"Bob Williams\",\"department\":\"Engineering\",\"position\":\"Developer\",\"vacationDaysRemaining\":10,\"directReports\":[]}]}]"
      },
      "traceId": "b11e80a3-d835-4baa-8619-d3fb1828424d-0",
      "type": "ACTION_GROUP"
    }
  ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. m Effort estimation: medium module/aspnetcore-support p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

2 participants