This repo provides a backend for showcasing the human-in-the-loop capabilities in Amazon Bedrock, specifically focusing on Return of Control (ROC) functionality. This repo is for demonstrative purposes only, and the application code is not meant for production use. The implementation demonstrates how to build intelligent HR assistants that can handle time-off requests with varying levels of human oversight. This allows organizations to maintain appropriate control and verification of automated processes while leveraging AI capabilities.
The provided APIs demonstrate three key patterns:
- Direct automation without human intervention
- Confirmation-based workflows requiring human approval
- Return of Control (ROC) scenarios where human input or verification is needed
Before getting started, ensure you have the following installed:
- Python 3.10+
- Streamlit
- AWS CLI configured with appropriate credentials and permissions
- AWS CLI Environment Variable setup. Credentials used need to have permissions to CloudFormation, IAM, Bedrock, and Lambda. If you use PowerUser or Admin permissions, temporary credentials are recommended.
- Bedrock Foundation model access. Ensure that you have access to Haiku 3.5 in
us-west-2
at a minimum. - Using
us-west-2
is required to use Haiku 3.5 at the time of publishing.
If you are new to Python, be sure to read through venv documentation as you will need to use this to deploy the agent using the CDK and run the frontend application locally.
The application consists of two main components that need to be deployed:
-
Backend Infrastructure
- Navigate to the CDK implementation for detailed deployment instructions
- This will create the necessary AWS resources including Lambda functions and Bedrock Agent
-
Frontend Application
- Follow the setup instructions in the Frontend guide
- This will deploy the Streamlit interface for interacting with the Bedrock Agent
Once deployed, you'll be able to interact with an interface similar to the one shown below:
Caution
Disclaimer: The current backend API does not do input validation and sanitizaton. After performing return-of-control, the agent does not do further validation on any data. E.g. if you change the request to 100 days, the API layer is responsible for handling the request accordingly and this demonstration does not do that.
The interface supports three different interaction modes:
-
Direct Processing
- Agent processes time-off requests automatically without human intervention
- Suitable for straightforward requests within standard parameters
-
Confirmation Required
- Agent presents the request details and waits for human confirmation
- User must explicitly approve or reject the request before it's processed
-
Return of Control (ROC) (This mode is showcased in the image above)
- Agent collects initial request details but returns control to the user
- Allows modification of request parameters (dates, duration)
- Final request is processed only after human review and adjustment
- Deploy the Amazon Bedrock Agent using the the CDK implementation guide in the repo.
- Confirm the default behavior of the agent in the AWS console by using a prompt like "I'd like to request time off for 3 days starting 2025-07-05."
- Set up the frontend using the Frontend guide.
- Update the Bedrock agent manually to use confirmation and/or return of control. See the CDK implementation guide for more details.
- Update the frontend environment variables and rerun. More details can be found in the Frontend guide.
I'd like to request 3 days off for 2025-07-03.
- Learn more about what other models are on Amazon Bedrock.
- Host your frontend on AWS Amplify.
- Implement Responsible AI on your Agent utilizing Guardrails on Amazon Bedrock.
See clean up.