Skip to content

aws-samples/sample-multi-agent-loan-processing

Multi-Agent Loan Processing System

Overview

This application showcases a multi-agent architecture for automated loan processing, where four specialized agents work sequentially to process loan applications from initial submission through final compliance review.

Agent Workflow

User Application → Concierge → Document Verification → Processing → Compliance → Decision
  1. Concierge Agent: Collects and stores user information and supporting documents
  2. Document Verification Agent: Validates uploaded documents against submitted data
  3. Processing Agent: Performs credit analysis, underwriting calculations, and risk assessment
  4. Compliance Agent: Conducts final regulatory review and prepares decision package

Architecture

Agents

1. Concierge Agent

Responsibility: Initial data collection

  • Stores user information (personal details, financial data)
  • Uploads supporting documents (ID, income proof, bank statements, credit reports)
  • Tools: store_user_info, upload_file

2. Document Verification Agent

Responsibility: Document validation

  • Fetches and reads uploaded documents
  • Extracts key information from PDFs
  • Verifies document contents match submitted user data
  • Tools: fetch_documents_from_session, fetch_user_from_session

3. Processing Agent

Responsibility: Financial analysis and underwriting

  • Analyzes income documents, bank statements, and credit reports
  • Calculates debt-to-income (DTI) ratios
  • Performs risk scoring and credit analysis
  • Generates preliminary approval decisions
  • Tools: fetch_user_from_session, fetch_documents_from_session, calculate_underwriting_metrics, simulate_credit_bureau_data

4. Compliance Agent

Responsibility: Final review and regulatory compliance

  • Consolidates all application data and analysis results
  • Reviews complete documentation package
  • Ensures regulatory compliance (Reg B, TILA, Fair Lending)
  • Prepares final decision package for human review
  • Tools: None (review-only agent)

Tools

Storage Tools (tools/storage_tools.py)

  • store_user_info: Stores applicant data in session memory
  • upload_file: Stores documents with PDF text extraction
  • fetch_documents_from_session: Retrieves documents with extracted content
  • fetch_user_from_session: Retrieves user data
  • get_session_status: Returns storage statistics
  • clear_session_storage: Clears all session data

Financial Tools (tools/financial_tools.py)

  • simulate_credit_bureau_data: Generates credit bureau data for analysis
  • calculate_underwriting_metrics: Performs underwriting calculations including DTI, risk scores, and approval decisions

Prerequisites

  • Python 3.8 or higher
  • AWS credentials configured with access to Amazon Bedrock
  • AWS Bedrock model access (Claude 3.7 Sonnet)

Installation

  1. Clone the repository:
git clone <repository-url>
cd sample-multi-agent-loan-processing
  1. Install dependencies:
pip install -r requirements.txt
  1. Configure AWS credentials: Ensure your AWS credentials are configured (via ~/.aws/credentials, environment variables, or IAM role):
aws configure
  1. Set up environment variables:
cp .env.example .env

Edit .env to configure the model (optional - defaults to Claude 3.7 Sonnet):

MODEL_ID=us.anthropic.claude-3-7-sonnet-20250219-v1:0
TEMPERATURE=0.3
TOP_P=0.8
  1. Prepare demo data (optional): Ensure sample PDF documents exist in the data/ directory for the demo workflow:
  • data/JoeDoeIDVerification.pdf
  • data/JoeDoePayStub.pdf
  • data/JoeDoeBankStatement.pdf
  • data/JoeDoeCreditReport.pdf

Usage

Running the Demo

The application includes a pre-configured demo workflow with sample data for testing:

python main.py

Select option [1] to run the demo workflow, which processes a sample loan application for "Joe Doe" through all four agents.

Project Structure

sample-multi-agent-loan-processing/
├── main.py                          # Main application entry point
├── config.py                        # Configuration management
├── requirements.txt                 # Python dependencies
├── .env.example                     # Environment variables template
├── agents/                          # Agent definitions
│   ├── __init__.py
│   ├── conceirge_agent.py          # Data collection agent
│   ├── document_verification_agent.py  # Document validation agent
│   ├── processing_agent.py         # Underwriting agent
│   └── compliance_agent.py         # Compliance review agent
├── tools/                           # Tool implementations
│   ├── __init__.py
│   ├── storage_tools.py            # Session storage management
│   └── financial_tools.py          # Financial calculations
└── data/                            # Sample documents (not included)
    ├── JoeDoeIDVerification.pdf
    ├── JoeDoePayStub.pdf
    ├── JoeDoeBankStatement.pdf
    └── JoeDoeCreditReport.pdf

Technologies Used

  • Strands Framework: Multi-agent orchestration framework
  • Amazon Bedrock: Foundation model service

Extending the System

Adding New Agents

Create a new agent in the agents/ directory following this pattern:

from strands import Agent
from strands.models import BedrockModel
from config import AgentConfig

config = AgentConfig()
model = BedrockModel(model_id=config.model_id)

my_agent = Agent(
    system_prompt="Your agent's instructions...",
    tools=[tool1, tool2],
    name="Agent Name",
    model=model
)

Adding New Tools

Define tools in the tools/ directory using the @tool decorator:

from strands import tool

@tool
def my_tool(param: str) -> str:
    """Tool description for the agent."""
    # Tool implementation
    return result

Customizing Underwriting Rules

Modify the logic in tools/financial_tools.py to adjust:

  • DTI thresholds
  • Credit score requirements
  • Risk scoring weights
  • Approval criteria

Security Considerations

  • Ensure AWS credentials are properly secured
  • Do not commit .env file or AWS credentials to version control
  • In production, replace session storage with secure database
  • Implement proper authentication and authorization
  • Encrypt sensitive financial data
  • Comply with relevant financial regulations (GLBA, FCRA, etc.)

Contributing

See CONTRIBUTING.md for guidelines on contributing to this project.

Security

See CONTRIBUTING for information on reporting security issues.

License

This library is licensed under the MIT-0 License. See the LICENSE file for details.

Acknowledgments

This project demonstrates AWS Bedrock capabilities and multi-agent architectures using the Strands framework. It is intended for educational and demonstration purposes only. This is not meant for use in production.

About

This application showcases a multi-agent architecture for automated loan processing, where four specialized agents work sequentially to process loan applications from initial submission through final compliance review.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors

Languages