Skip to content

feat(event-handler): add Amazon Bedrock Agents Functions Resolver #3957

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

Merged
merged 17 commits into from
May 26, 2025

Conversation

svozza
Copy link
Contributor

@svozza svozza commented May 21, 2025

Summary

Adds a new resolver type to the event-handler package to handle lambda functions invoked by Amazon Bedrock agents.

Changes

  • Adds a new resolver class for Bedrock agents function
  • The resolver class has two public methods:
    • tool - takes an async function and a configuration object with name and description fields and registers the tool
    • resolve - accepts the lambda event and context objects from the handler and routes the request to the correct tool and returns an appropriately formatted response. Can also be used as a method or a decorator.
  • Allow user functions that return both primitive values or complex types( as long as they are JSON serializable).
  • Performs checks when registering tools for the following scenarios
    • Attempting to register more than 5 tools
    • Overwriting an existing tool
    • Receiving an event for a non-existent tool
  • Unit tests

Issue number: #3710

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@boring-cyborg boring-cyborg bot added dependencies Changes that touch dependencies, e.g. Dependabot, etc. event-handler This item relates to the Event Handler Utility tests PRs that add or change tests labels May 21, 2025
@pull-request-size pull-request-size bot added the size/XL PRs between 500-999 LOC, often PRs that grown with feedback label May 21, 2025
@dreamorosi dreamorosi changed the title wip(event-handler): add Amazon Bedrock Agents Functions Resolver feat(event-handler): add Amazon Bedrock Agents Functions Resolver May 21, 2025

This comment was marked as outdated.

@github-actions github-actions bot added do-not-merge This item should not be merged need-issue This PR needs an issue before it can be reviewed/worked on further feature PRs that introduce new features or minor changes labels May 21, 2025
@svozza svozza force-pushed the bedrock-agent-resolver branch from aa4e007 to 59db37b Compare May 21, 2025 15:29
@dreamorosi dreamorosi removed need-issue This PR needs an issue before it can be reviewed/worked on further do-not-merge This item should not be merged labels May 21, 2025
@svozza svozza force-pushed the bedrock-agent-resolver branch 2 times, most recently from 883fbfd to 6212f21 Compare May 21, 2025 15:43
@svozza svozza marked this pull request as draft May 21, 2025 15:46
@dreamorosi dreamorosi linked an issue May 21, 2025 that may be closed by this pull request
2 tasks
@svozza svozza force-pushed the bedrock-agent-resolver branch from 6212f21 to 823d4b5 Compare May 22, 2025 12:59
Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this PR, I was able to test this with this sample agent and it works both with simple inputs and arrays (once the changes are applied).

I've left a number of comments, once these are addressed I'll focus on testing also the decorator pattern that I haven't really tested yet (see comments), so there might be an additional round of review after this one.

@svozza svozza force-pushed the bedrock-agent-resolver branch from 3112527 to 1998e86 Compare May 23, 2025 23:52
@svozza svozza marked this pull request as ready for review May 24, 2025 12:36
@svozza svozza force-pushed the bedrock-agent-resolver branch from 3c27cc1 to c916396 Compare May 26, 2025 08:55
@dreamorosi dreamorosi self-requested a review May 26, 2025 15:52
dreamorosi
dreamorosi previously approved these changes May 26, 2025
Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the exports in the package.json is still using the old path - other than that I'm good to merge it.

Copy link

@svozza
Copy link
Contributor Author

svozza commented May 26, 2025

Done!

@dreamorosi
Copy link
Contributor

Thank you for the great work and many iterations @svozza, good job!

@svozza
Copy link
Contributor Author

svozza commented May 26, 2025

No problem, really happy with where we ended up here!

@dreamorosi dreamorosi merged commit 720ddcb into aws-powertools:main May 26, 2025
41 checks passed
@svozza svozza deleted the bedrock-agent-resolver branch May 26, 2025 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Changes that touch dependencies, e.g. Dependabot, etc. event-handler This item relates to the Event Handler Utility feature PRs that introduce new features or minor changes size/XXL PRs with 1K+ LOC, largely documentation related tests PRs that add or change tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Amazon Bedrock Agents Functions
2 participants