AWS Step Functions with Amazon Bedrock AgentCore Harness Optimized Integration (CDK)

AWS Step Functions → Amazon Bedrock AgentCore

Invoke Amazon Bedrock AgentCore harness from AWS Step Functions using the optimized integration — zero Lambda, Converse-shaped responses, and token metrics.

This pattern uses the AWS Step Functions optimized integration for Amazon Bedrock AgentCore to invoke a harness directly — no Lambda function required.
The harness orchestrates model inference, tool use, and multi-turn conversations. Step Functions receives a Converse-shaped response with aggregated token usage metrics.
The optimized integration provides CloudWatch deep-links for turn-by-turn agent reasoning traces, built-in retry/catch for throttling, and a 15-minute execution timeout.
The state machine includes error handling with specific catches for ResourceNotFoundException and ThrottlingException with exponential backoff.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/sfn-bedrockagentcore-harness-cdk

Deploy

cdk bootstrapnpm installcdk deploy --parameters HarnessArn=arn:aws:bedrock-agentcore:us-east-1:ACCOUNT:harness/YOUR-HARNESS


Testing

Start an execution with a prompt:
aws stepfunctions start-execution --state-machine-arn $(aws cloudformation describe-stacks --stack-name SfnBedrockagentcoreHarnessStack --query 'Stacks[0].Outputs[?OutputKey==`StateMachineArn`].OutputValue' --output text) --input '{"prompt": "What is Amazon Bedrock AgentCore?"}'
Check execution output (wait 10-30 seconds for agent reasoning):
aws stepfunctions describe-execution --execution-arn EXECUTION_ARN --query 'output'

Cleanup

cdk destroy

Created by:

Nithin Chandran R

Nithin Chandran R

Technical Account Manager at AWS

Follow on LinkedIn