New serverless pattern - sam-dotnet-responsestreaming-bedrock-agent - #3236
Conversation
marcojahn
left a comment
There was a problem hiding this comment.
Hello @dougperkes , thank you for you PR. I've added some review comments, please review.
| Action: | ||
| - bedrock:InvokeModelWithResponseStream | ||
| - bedrock:InvokeModel | ||
| Resource: "*" |
There was a problem hiding this comment.
The Lambda execution policy grants bedrock:InvokeModel and bedrock:InvokeModelWithResponseStream on Resource: "*", allowing the function to invoke any Bedrock model in the account. The actions are already scoped, but the resource can be narrowed to the specific inference profile and its underlying foundation models. Additionally, the code calls the Converse API (ConverseAsync), which only requires bedrock:InvokeModel — bedrock:InvokeModelWithResponseStream is granted but unused (it is only needed for ConverseStream).
|
|
||
| --- | ||
|
|
||
| ## Prerequisites |
There was a problem hiding this comment.
Please add, that the sample will incur costs in the used AWS account
| /// </summary> | ||
| public class TripPlannerAgent | ||
| { | ||
| private const string ModelId = "us.anthropic.claude-sonnet-5"; |
There was a problem hiding this comment.
US only for the sample. Please either indicate in the README.md that the access to an US region is required or (preferred) make the model choice configuration/derived from used region.
| - [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) | ||
| - [AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html) | ||
| - AWS account with credentials configured (`aws configure`) | ||
| - **Amazon Bedrock model access** — Enable access to Claude Sonnet in the [Bedrock console](https://console.aws.amazon.com/bedrock/home#/modelaccess) |
There was a problem hiding this comment.
not needed since ~Nov/2025
| @@ -0,0 +1,214 @@ | |||
| # AWS Lambda Response Streaming with Bedrock Agent — AI Trip Planner (.NET) | |||
There was a problem hiding this comment.
| # AWS Lambda Response Streaming with Bedrock Agent — AI Trip Planner (.NET) | |
| # AWS Lambda Response Streaming with Amazon Bedrock Agents — AI Trip Planner (.NET) |
| @@ -0,0 +1,214 @@ | |||
| # AWS Lambda Response Streaming with Bedrock Agent — AI Trip Planner (.NET) | |||
|
|
|||
| This sample demonstrates an **AI agent** built with Amazon Bedrock (Claude Sonnet) **tool use** combined with **Lambda Response Streaming through API Gateway**. The agent uses a tool-calling loop to build a day-by-day trip itinerary, streaming each day's plan to the client as it's generated. | |||
There was a problem hiding this comment.
| This sample demonstrates an **AI agent** built with Amazon Bedrock (Claude Sonnet) **tool use** combined with **Lambda Response Streaming through API Gateway**. The agent uses a tool-calling loop to build a day-by-day trip itinerary, streaming each day's plan to the client as it's generated. | |
| This sample demonstrates an **AI agent** built with Amazon Bedrock (Claude Sonnet) **tool use** combined with **AWS Lambda Response Streaming through Amazon API Gateway**. The agent uses a tool-calling loop to build a day-by-day trip itinerary, streaming each day's plan to the client as it's generated. |
| # ───────────────────────────────────────────────────────────────────── | ||
| # Lambda Function — AI trip planner agent with tool use | ||
| # ───────────────────────────────────────────────────────────────────── | ||
| TripPlannerFunction: |
There was a problem hiding this comment.
The pattern does not define a log group with a retention policy for the Lambda function. By default the implicitly created log group retains logs indefinitely, accumulating storage cost over time.
TripPlannerLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub /aws/lambda/${TripPlannerFunction}
RetentionInDays: 14| Type: AWS_PROXY | ||
| IntegrationHttpMethod: POST | ||
| ResponseTransferMode: STREAM | ||
| TimeoutInMillis: 120000 |
There was a problem hiding this comment.
The integration sets TimeoutInMillis: 120000 (120s). The default API Gateway integration timeout quota is 29 seconds; to have values above it taking any effect, require a service quota increase for Regional/private REST APIs. If the account's quota has not been raised, and the sample requires it, it will not work as intended.
(preferred): make the sample guaranteed to work with the default quota, or mention in the README.md the quote increase is needed and why
Issue #, if available:
Description of changes: Lambda Response Streaming with Amazon Bedrock — Story Generator (.NET)
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.