Skip to content

Feature request: Amazon Bedrock Agents Functions #887

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

Open
1 of 2 tasks
hjgraca opened this issue May 16, 2025 · 0 comments
Open
1 of 2 tasks

Feature request: Amazon Bedrock Agents Functions #887

hjgraca opened this issue May 16, 2025 · 0 comments
Assignees
Labels
event_handlers feature-request New or enhancements to existing features

Comments

@hjgraca
Copy link
Contributor

hjgraca commented May 16, 2025

Use case

Bedrock Agents allows you to define action groups for your agents in two ways: OpenAPI schemas, and direct function integration. This issue focuses on the latter.

As a customer I can create Bedrock Agents that have tools at their disposal. These tools, or functions, can be defined as AWS Lambda functions. One Lambda function can hold one or more tools and when looked at together, they are what makes an action group.

When I build a Lambda function with multiple tools in it, I am responsible for parsing the payload sent by Bedrock and, based on certain fields, call the corresponding tool in my code (aka the tool use). The response of this tool use is then returned by my Lambda function handler according to a specific format that Bedrock expects.

This can result in some degree of boilerplate code that I have to repeat for each action group, specifically:

parsing/validating the incoming Bedrock Agent request payload
handling the event using the correct tool/function
building the response according to the response Bedrock Agent payload schema

More details aws-powertools/powertools-lambda-typescript#3710

Solution/User Experience

When paired with a Lambda function via action group, Bedrock sends and expects payloads of known shapes.

Payload Example Documentation

{
    "messageVersion": "1.0",
    "agent": {
        "alias": "PROD",
        "name": "hr-assistant-function-def",
        "version": "1",
        "id": "1234abcd-56ef-78gh-90ij-klmn12345678"
    },
    "sessionId": "87654321-abcd-efgh-ijkl-mnop12345678",
    "sessionAttributes": {
        "employeeId": "EMP123",
        "department": "Engineering"
    },
    "promptSessionAttributes": {
        "lastInteraction": "2024-02-01T15:30:00Z",
        "requestType": "vacation"
    },
    "inputText": "I want to request vacation from March 15 to March 20",
    "actionGroup": "VacationsActionGroup",
    "function": "submitVacationRequest",
    "parameters": [{
        "employeeId": "EMP123",
        "startDate": "2024-03-15",
        "endDate": "2024-03-20",
        "vacationType": "annual"
    }]
}

Payload example Documentation

{
   "response":{
      "actionGroup":"SmarterAgentActionGroup",
      "function":"submitVacationRequest",
      "functionResponse":{
         "responseBody":{
            "TEXT":{
               "body":"Your vacation was scheduled!"
            }
         }
      }
   },
   "messageVersion":"1.0"
}

Since the input event includes both the function and parameters fields, we can abstract most/all the boilerplate and provide a more streamlined experience.

For example, borrowing heavily from the aws-powertools/powertools-lambda-typescript#3500 we concluded a few weeks ago, we could implement a BedrockAgentFunctionResolver resolver that provides a structured way to register functions, resolve function calls, and handle requests within Lambda.

Alternative solutions

Acknowledgment

@hjgraca hjgraca self-assigned this May 16, 2025
@hjgraca hjgraca added feature-request New or enhancements to existing features event_handlers labels May 16, 2025
@hjgraca hjgraca moved this to 📋 Backlog in Powertools for AWS Lambda (.NET) May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
event_handlers feature-request New or enhancements to existing features
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant