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.
User Application → Concierge → Document Verification → Processing → Compliance → Decision
- Concierge Agent: Collects and stores user information and supporting documents
- Document Verification Agent: Validates uploaded documents against submitted data
- Processing Agent: Performs credit analysis, underwriting calculations, and risk assessment
- Compliance Agent: Conducts final regulatory review and prepares decision package
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
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
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
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)
store_user_info: Stores applicant data in session memoryupload_file: Stores documents with PDF text extractionfetch_documents_from_session: Retrieves documents with extracted contentfetch_user_from_session: Retrieves user dataget_session_status: Returns storage statisticsclear_session_storage: Clears all session data
simulate_credit_bureau_data: Generates credit bureau data for analysiscalculate_underwriting_metrics: Performs underwriting calculations including DTI, risk scores, and approval decisions
- Python 3.8 or higher
- AWS credentials configured with access to Amazon Bedrock
- AWS Bedrock model access (Claude 3.7 Sonnet)
- Clone the repository:
git clone <repository-url>
cd sample-multi-agent-loan-processing- Install dependencies:
pip install -r requirements.txt- Configure AWS credentials:
Ensure your AWS credentials are configured (via
~/.aws/credentials, environment variables, or IAM role):
aws configure- Set up environment variables:
cp .env.example .envEdit .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
- Prepare demo data (optional):
Ensure sample PDF documents exist in the
data/directory for the demo workflow:
data/JoeDoeIDVerification.pdfdata/JoeDoePayStub.pdfdata/JoeDoeBankStatement.pdfdata/JoeDoeCreditReport.pdf
The application includes a pre-configured demo workflow with sample data for testing:
python main.pySelect option [1] to run the demo workflow, which processes a sample loan application for "Joe Doe" through all four agents.
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
- Strands Framework: Multi-agent orchestration framework
- Amazon Bedrock: Foundation model service
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
)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 resultModify the logic in tools/financial_tools.py to adjust:
- DTI thresholds
- Credit score requirements
- Risk scoring weights
- Approval criteria
- Ensure AWS credentials are properly secured
- Do not commit
.envfile 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.)
See CONTRIBUTING.md for guidelines on contributing to this project.
See CONTRIBUTING for information on reporting security issues.
This library is licensed under the MIT-0 License. See the LICENSE file for details.
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.