Mortgage Preapproval Agent Ebook
How to Build an AI Agent
This is the supplementary notebook for the E-book and LLM University module on building an AI agent.
The module provides a step-by-step guide to building AI agents with the following chapters:
- Define the scope of your AI agent
- Select your model and implementation approach
- Create tools for your AI agent
- Orchestrate and integrate your AI agent
- Evaluate your AI agent and review its performance
- Deploy your AI agent
Module 0: Introduction
This notebook demonstrates how to build a production-ready AI agent that automates the mortgage pre-approval process.
What You'll Learn
This notebook guides you through building a fully functional mortgage pre-approval AI agent following our proven six-step framework:
- Defining the scope of your AI Agent: Clearly outline the business problem, success metrics, and workflow
- Selecting the large language model: Choose the right model to power your agent based on specific requirements and architectural needs
- Creating the agent's tools: Build specialized functions that give your agent abilities to take actions
- Orchestrating workflows: Design the system that brings everything together into a seamless process
- Evaluating performance: Test and refine your agent to ensure reliability and accuracy
- Deploy to production: Move your agent from development to real-world use
What is an AI Agent?
AI agents are advanced software programs designed to independently reason, access information from various sources, and execute intricate tasks across the enterprise.
Equipped with specialized tools — connections to company-wide systems — they navigate complex workflows step by step, delivering efficiency and precision with minimal human intervention.
These applications redefine how businesses work, enabling scalable operations, smarter decision-making, and seamless integration across systems.
Why Use AI Agents for Mortgage Processing?
Mortgage processing involves numerous manual tasks ideal for automation:
- Credit checks across multiple bureaus
- Employment verification
- Document processing and report generation
By automating these processes, institutions can reduce processing time from hours to minutes, improve accuracy, and let loan officers focus on customer relationships.
⚠️ IMPORTANT: Generate Your Cohere API Key ⚠️
Before continuing, you must generate an API key from Cohere:
- Go to https://dashboard.cohere.com/welcome/register
- Create an account or sign in
- Navigate to API keys section
- Generate a new API key
- Copy your API key
- Replace "your-api-key-here" in the cell below with your actual key
This notebook will not function without a valid API key.
Module 1 complete: Environment and dependencies initialized.
Module 1: Define the scope of your AI Agent
Begin by clearly defining your agent's purpose by interviewing stakeholders and gathering requirements. Document the specific business problem you're solving and outline measurable success criteria.
Business Problem
Loan officers spend an average of five hours gathering and verifying information for each pre-approval request. This manual process includes checking credit scores, verifying employment, and writing summary reports.
Success Metrics
- Increase loans processed by 3x in the first year of agent deployment
- Decrease loan officer analysis time from five hours to five minutes
- 98% credit check accuracy (on par with human-level)
Required Actions
- Receive customer information (triggered by the submission of a mortgage application)
- Build applicant profile for final verification, which consists of:
- Checking credit scores from all three credit bureaus by querying each bureau's API
- Updating customer record with credit info
- Sending employment verification by generating verification email with customer information
- Processing verification response by extracting verification information and updating customer record
- Generate final report by analyzing credit data and employment status, and then creating recommendation
- Review agent recommendation (conducted by human mortgage loan officer)
Workflow Diagram
Integration Points
To accomplish these tasks, our agent needs to interact with:
- Credit bureau APIs (Experian, Equifax, TransUnion)
- Internal customer database
- Email system for employment verification (SMTP)
Data Requirements
The agent will need access to:
- Customer personal information
- Social Security Number (for credit checks)
- Employment information
- Income details
Let's now set up a mock customer database to simulate our production environment.
Module 2 complete: Agent scope defined and mock data initialized.
Module 2: Selecting your large language model
After defining our agent's scope and setting up mock data, we need to select the appropriate model and architecture. This decision will determine the agent's capabilities, performance, and ability to handle the mortgage pre-approval workflow.
Required Capabilities
Our mortgage pre-approval agent needs:
- Multi-step reasoning: To navigate the complex flow from application to final recommendation
- Multi-step tool use: To interact with credit bureaus, database, and email systems
- Context maintenance: To retain customer information throughout the process
- Natural language generation: For creating detailed mortgage reports
- Structured outputs: To generate consistent, standardized data formats for decisions, reports, and system integrations
- Private deployment options: For handling sensitive financial data securely
Model Selection: Cohere Command A
For our implementation, we've selected Cohere Command A based on how it addresses our specific requirements:
-
Multi-step reasoning capability: Command A excels at complex reasoning tasks with the ability to plan ahead and execute multi-step workflows required for mortgage processing. Command A also matches or outperforms models like GPT-4o and DeepSeek-V3 on enterprise tasks while requiring significantly less compute resources.
-
Proven performance on multi-step tool use: Command A excels at complex reasoning tasks with the ability to plan ahead and execute multi-step workflows required for mortgage processing.
-
Context management: With a 256k token context window (2x most leading models), Command A can maintain comprehensive customer information throughout the entire approval process without losing important details.
-
High-quality content generation: Command A produces clear, detailed, and professional mortgage reports that match human-quality standards with appropriate formatting and structure.
-
Deployment flexibility: Command A can be deployed privately on as few as two GPUs, making it cost-effective for financial institutions with strict data privacy requirements for sensitive financial data.
✅ API connection successful Sample output: Hello! How can I assist you today?... Module 3 complete: Model and architecture selected.
Module 3: Creating the agent's tools
After selecting our model and architecture, we need to create the tools our AI agent will use to interact with external systems. In the context of AI agents, tools are specialized functions that give the agent the ability to perform specific actions, such as checking credit scores or sending emails.
The Tool Creation Pattern
For our mortgage pre-approval agent, we'll implement a three-part pattern for each tool:
- Tool Definition: A structured description that helps the model understand the tool's purpose and parameters
- Tool Function: The actual code implementation that performs a specific action
- Function Mapping: The connection between the model's tool calls and the actual functions to execute
This pattern creates a clean separation between what the model knows about a tool and how it's implemented, allowing for better maintenance and extensibility.
Credit Bureau Tools
Let's start by creating tools for checking credit scores from the three major bureaus. These tools abstract away the complexity of connecting to credit bureau APIs and provide a clean interface for our agent to use.
In a production environment, these would connect to actual credit bureau APIs, but for this demonstration, we'll use mock databases.
Credit Check Tool Test: {'credit_score': 720, 'report_date': '2025-03-15'}
Customer Record Management Tool
Next, we need a tool to update the customer database with information collected during the pre-approval process. This tool implements a data persistence pattern with error handling, ensuring customer data is properly maintained throughout the process.
This pattern is crucial for maintaining state across multiple steps in the mortgage pre-approval workflow. It ensures that information gathered at earlier steps (like credit scores) is available for later steps (like final report generation).
Database Update Tool Test: {'status': 'success', 'message': 'Updated credit info for CUS20240111105523'}
Employment Verification Tools
A critical part of the pre-approval process is verifying the applicant's employment. We'll create tools for:
- Sending verification requests: Generating and sending an employment verification email
- Processing verification responses: Handling the employer's response and updating records
These tools implement two important patterns:
- External communication pattern: For generating professional emails with appropriate information
- Data processing pattern: For extracting structured information from responses
In a production environment, these would connect to an actual email system, but for this demonstration, we'll simulate the process.
Email Verification Tool Test: Successful
Report Generation Tool
The final step in our pre-approval process is generating a comprehensive report for the loan officer. This tool leverages Cohere's Command A model to analyze all the collected data and produce a detailed assessment.
This tool implements a report generation pattern using an LLM, allowing for sophisticated analysis and natural language output that synthesizes all the collected information into an actionable recommendation.
In a production environment, this report would be reviewed by a human loan officer before making the final decision.
Report Generation Tool defined
Tool Definitions for the AI Agent
For our AI agent to use the tools we've created, we need to define them in a format that the model can understand. These definitions include the name, description, and parameter specifications for each tool.
Well-crafted tool definitions are as important as good prompt engineering. They help the model decide when and how to use each tool appropriately. Each definition includes:
- A clear, specific name that indicates the tool's purpose
- A detailed description of what the tool does
- Parameter specifications with types and descriptions
- Required parameters clearly marked
In the next module, we'll bring these tools together in an orchestration framework that allows the agent to execute the entire mortgage pre-approval workflow.
Module 4 complete: Tools created and defined for our mortgage pre-approval agent
Function Mapping
After creating our individual tools, we need to establish a mapping between the tool names and their actual function implementations. This function mapping serves as a lookup table that connects the tool names referenced in our agent's tool definitions to the corresponding Python function implementations.
Let's create our function mapping:
Function mapping established: Tool names are now connected to their implementations.
Module 4: Orchestrating agentic workflows
Now that we've created our tools and function mappings, we'll orchestrate everything into a cohesive workflow. This involves combining our components into a process that handles the entire mortgage pre-approval journey.
1. Workflow Mapping
Our mortgage pre-approval agent follows this workflow:
- Receive customer information
- Check credit scores from all three bureaus
- Update customer record with credit info
- Send employment verification email
- Wait for verification response and process it
- Generate final report
This follows the ReAct (Reasoning + Acting) pattern where the agent alternates between reasoning and taking action.
2. System Design
Our system design handles:
- State Management: Maintaining customer information and conversation history
- Tool Execution: Invoking tools based on the agent's decisions
- Error Handling: Recovering from failures
- Progress Tracking: Monitoring workflow progress
3. Prompt Design
The system prompt guides the agent's behavior by providing:
- Clear instructions on the overall goal
- Access to relevant customer information
- A step-by-step workflow
- Guidelines on when to use each tool
4. The Orchestration Loop
Our orchestration loop implements the ReAct pattern, connecting all components to create a seamless workflow that efficiently processes mortgage applications while maintaining context throughout the entire process.
Understanding the ReAct Pattern Implementation
Our implementation follows the ReAct (Reasoning + Acting) pattern, which consists of three key phases:
- Reasoning: The agent analyzes the current state and decides what to do next
- Acting: The agent executes the chosen action through a tool call
- Observing: The agent processes the result and updates its understanding
Let's examine how this works in our mortgage pre-approval workflow:
- When processing a new application, the agent first reasons about which credit bureau to check
- It then acts by calling the appropriate credit check tool
- It observes the credit score result and incorporates it into its knowledge
This cycle repeats as the agent works through the entire process, making decisions based on the information it gathers along the way. For example, if a credit score is low, the agent might note this as a risk factor in the final report.
Error Handling and Edge Cases
Our implementation includes several mechanisms for handling errors and edge cases:
- Maximum step limit to prevent infinite loops
- Tool result validation to ensure data consistency
- Special handling for different types of tools
- Clear progress reporting for monitoring
These safeguards ensure that the agent can recover from unexpected situations and either complete the workflow or provide a clear indication of what went wrong.
Let's test our agent with a sample mortgage application to see the entire workflow in action. This will take 1-2 minutes to process.
PHASE 1: INITIAL PROCESSING
==================================================
==================================================
EXECUTION PLAN:
==================================================
I will use the customer data to check the credit scores from all bureaus, update the customer record with credit info, send employment verification email to the employer's HR department, and once employment is verified, write the final report.
==================================================
------------------------------
Executing: check_experian
Parameters: {
"name": "Michael Scott",
"ssn": "123-45-6789"
}
Result: {
"credit_score": 720,
"report_date": "2025-03-15"
}
------------------------------
Executing: check_equifax
Parameters: {
"name": "Michael Scott",
"ssn": "123-45-6789"
}
Result: {
"credit_score": 715,
"report_date": "2025-03-15"
}
------------------------------
Executing: check_transunion
Parameters: {
"name": "Michael Scott",
"ssn": "123-45-6789"
}
Result: {
"credit_score": 718,
"report_date": "2025-03-15"
}
------------------------------
Executing: update_customer_record
Parameters: {
"customer_id": "CUS20240111105523",
"credit_info": {
"experian": 720,
"equifax": 715,
"transunion": 718
}
}
Result: {
"status": "success",
"message": "Updated credit info for CUS20240111105523"
}
------------------------------
Executing: send_employment_verification_email
Parameters: {
"employer_name": "Dunder Mifflin Paper Company",
"employee_name": "Michael Scott",
"employer_email": "hr@dundermifflin.com",
"salary": 95000.0
}
Result: {
"status": "sent",
"to": "hr@dundermifflin.com",
"verification_status": "PENDING"
}
------------------------------
==================================================
Waiting for employer verification response...
==================================================
Here is the final report for Michael Scott's mortgage pre-approval:
**Mortgage Application Review Report**
**Report Date:** 2025-03-19
**Applicant:** Michael Scott
**Application ID:** CUS20240111105523
**Application Date:** 2025-03-12
**Prepared by:** Mortgage Processing System
---
### **Executive Summary**
This report provides a comprehensive review of Michael Scott’s mortgage application, focusing on credit profile, employment verification, income, and tax information. The analysis highlights key factors to assist in the decision-making process.
---
### **1. Credit Profile Analysis**
**Credit Scores:**
- Experian: 720
- Equifax: 715
- TransUnion: 718
**Implications:**
Michael Scott’s credit scores fall within the "good" range (typically 670–739), indicating a solid credit history. Lenders generally view this range favorably, as it suggests a lower risk of default. However, the slight variation in scores (715–720) may warrant a closer look at credit reports to ensure no discrepancies or red flags exist.
**Recommendations:**
- Review credit reports for any outstanding debts, late payments, or discrepancies.
- Consider offering a competitive interest rate based on the strong credit profile.
---
### **2. Employment Verification Status**
**Status:** PENDING
**Employer:** Dunder Mifflin Paper Company
**Request Date:** 2025-03-19
**Implications:**
Employment verification is still pending, which is a critical step in confirming the applicant’s income stability and ability to repay the loan. Without verified employment, the application cannot proceed to final approval.
**Recommendations:**
- Expedite employment verification with Dunder Mifflin Paper Company.
- Confirm the reported salary of $95,000 aligns with employer records.
---
### **3. Income and Tax Information Review**
**Income Details:**
- Hourly Rate: $45.67
- Net Pay: $2,643.38
- Annual Salary: $95,000
- Federal Tax Withheld: $19,000
**Implications:**
The reported annual salary of $95,000 is consistent across employment and income details, providing confidence in the applicant’s stated income. The federal tax withheld aligns with typical tax obligations for this income level, suggesting no irregularities.
**Recommendations:**
- Verify income stability through pay stubs or tax returns.
- Assess debt-to-income ratio (DTI) once employment is confirmed.
---
### **4. Potential Concerns and Positive Factors**
**Positive Factors:**
1. **Strong Credit Profile:** Scores above 700 indicate a reliable borrower.
2. **Consistent Income Reporting:** Salary aligns across all documents.
3. **Established Employer:** Dunder Mifflin Paper Company is a recognized entity, adding credibility to employment claims.
**Potential Concerns:**
1. **Pending Employment Verification:** Delays approval and introduces uncertainty.
2. **Slight Credit Score Variation:** Minor discrepancies may require further investigation.
---
### **5. Context for Decision Making**
Michael Scott’s application demonstrates several positive factors, including a strong credit profile and consistent income reporting. However, the pending employment verification is a critical hurdle that must be addressed before proceeding. Once employment is confirmed, the application appears to be a strong candidate for approval, provided the debt-to-income ratio and other underwriting criteria are met.
**Next Steps:**
1. Prioritize employment verification with Dunder Mifflin Paper Company.
2. Review credit reports for any discrepancies or red flags.
3. Calculate DTI and assess overall affordability once income is verified.
---
**Prepared by:**
Mortgage Processing System
**Report Date:** 2025-03-19
PHASE 2: EMPLOYMENT VERIFICATION AND FINAL REPORT
==================================================
==================================================
Processing employer verification response...
==================================================
==================================================
Employer verification complete. Generating final report...
==================================================
==================================================
EXECUTION PLAN:
==================================================
I will use the write_final_report tool to generate the final report.
==================================================
------------------------------
Here is the final report for Michael Scott's mortgage application:
**Mortgage Application Review Report**
**Report Date****:** 2025-03-19
**Applicant****:** Michael Scott
**Application ID****:** CUS20240111105523
**Application Date****:** 2025-03-12
**Prepared by****:** Mortgage Processing System
---
### **Executive Summary**
This report provides a comprehensive review of Michael Scott's mortgage application, analyzing key factors including credit profile, employment verification, income, and tax information. The findings are intended to assist the loan officer in making an informed decision.
---
### **1. Credit Profile Analysis**
**Credit Scores****:**
- **Experian****:** 720
- **Equifax****:** 715
- **TransUnion****:** 718
**Implications****:**
Michael Scott’s credit scores across all three bureaus are strong, averaging 718. This places him in the "good" credit range, indicating a history of responsible credit management. Lenders typically view scores in this range favorably, as they suggest a lower risk of default.
**Positive Factor****:**
The consistent credit scores across bureaus demonstrate financial stability and reliability.
---
### **2. Employment Verification**
**Employer****:** Dunder Mifflin Paper Company
**Position****:** Regional Manager
**Employment Length****:** 15 years
**Employment Status****:** ACTIVE
**Reported Salary****:** $95,000.00 (verified)
**Implications****:**
Michael Scott’s employment has been fully verified, confirming his long-term stability with the same employer. His position as Regional Manager and 15 years of tenure highlight a strong career foundation, which is a positive indicator of consistent income.
**Positive Factor****:**
Long-term employment with a verified salary reduces risk associated with job instability.
---
### **3. Income and Tax Information**
**Annual Salary****:** $95,000.00
**Hourly Rate****:** $45.67
**Net Pay****:** $2,643.38
**Federal Tax Withheld****:** $19,000.00
**Implications****:**
Michael Scott’s annual income is substantial and aligns with his verified employment details. The net pay and federal tax withholding are consistent with his reported salary, indicating accurate financial reporting.
**Positive Factor****:**
A high and stable income provides a strong foundation for mortgage repayment capacity.
---
### **4. Potential Concerns or Positive Factors**
**Positive Factors****:**
1. **Strong Credit Profile****:** Scores above 700 across all bureaus indicate low credit risk.
2. **Long-Term Employment****:** 15 years with the same employer demonstrates stability and reliability.
3. **Verified Income****:** Consistent and substantial income supports repayment capacity.
**Potential Concerns****:**
1. **Tax Withholding****:** While federal tax withholding is reasonable, it is important to ensure that other financial obligations (e.g., state taxes, debts) do not significantly impact disposable income.
2. **Debt-to-Income Ratio (DTI)****:** Not explicitly provided in the application. Further analysis of monthly obligations is recommended to assess DTI.
---
### **5. Context for Decision Making**
Michael Scott’s application presents a strong case for mortgage approval. His excellent credit scores, long-term employment, and verified income are significant positive factors. However, a thorough review of his debt-to-income ratio and any additional financial obligations is essential to ensure he can comfortably manage mortgage payments.
**Recommendation****:**
Given the positive factors and minimal concerns, Michael Scott appears to be a low-risk candidate for mortgage approval. Further verification of his DTI and a review of his bank statements or other financial documents may provide additional confidence in his ability to meet repayment obligations.
---
**Prepared by****:**
Mortgage Processing System
**Report Date****:** 2025-03-19
Module 5 complete: Agent orchestration implemented and tested
Understanding the Agent Execution Results
The agent execution output above demonstrates the complete mortgage pre-approval workflow in action. Let's examine what happened:
Phase 1: Initial Processing
In the first phase, our agent:
- Created an execution plan outlining the steps it would take
- Gathered credit information from all three bureaus (Experian: 720, Equifax: 715, TransUnion: 718)
- Updated the customer record with this credit information
- Sent an employment verification email to Dunder Mifflin's HR department
- Generated an initial report with a status of "pending employment verification"
At this point, the agent reached a deliberate stopping point, waiting for external input (the employer's response) before proceeding further. This demonstrates how AI agents can handle multi-step processes that require human or external system intervention.
Phase 2: Employment Verification and Final Report
After receiving the employment verification response, the agent:
- Processed the verification data, confirming Michael's position and salary
- Generated a comprehensive final report with updated employment status
- Changed its recommendation from "pending verification" to "approve the application"
Notice how the final report contains much more specific and confident language based on the verified information. The agent successfully maintained context across both phases of execution, remembering the credit information gathered earlier while incorporating the new employment verification data.
This two-phase workflow exemplifies how our agent architecture excels at handling real-world mortgage processing tasks that involve:
- Multiple data sources (credit bureaus, employer verification)
- State maintenance across steps
- Waiting for external inputs
- Decision-making based on accumulated information
In a production environment, this agent could reduce a process that typically takes loan officers hours into just minutes, while maintaining accuracy and compliance with lending standards.
Now let's move on to evaluating our agent's performance.
Module 5: Evaluate Your AI Agent
Before moving to production, AI agents require comprehensive evaluation across multiple dimensions to ensure reliability, accuracy, and performance. While a holistic evaluation process is essential for production-ready agents, for our example we'll focus specifically on tool call accuracy - a critical metric for workflow-driven agents.
The Holistic Evaluation Process
A complete agent evaluation should include:
- Response Quality and Accuracy: Assessing report quality, factual correctness, and usefulness
- End-to-End Task Completion: Verifying successful navigation of the entire workflow
- Multi-Step Reasoning: Testing context retention and adaptation to new information
- Integration and Performance: Measuring reliability, latency, and scalability
These evaluations collectively build confidence in an agent's readiness for production deployment. For comprehensive assessment, tools like RAGAS and Weights & Biases Weave can provide structured frameworks and visualizations.
Tool Call Accuracy: Our Focus Metric
For our mortgage pre-approval agent, we're using the Tool Call Accuracy metric from RAGAS as our primary evaluation focus. This metric is particularly important for workflow-driven agents as it measures how well the agent uses its available tools compared to an expected reference pattern.
The Tool Call Accuracy metric evaluates:
- Whether tools are called in the correct sequence
- If the right parameters are passed to each tool
- Whether all necessary tools are used
While this metric alone isn't sufficient for production deployment, it provides a strong foundation for understanding the agent's core functionality and decision-making capability.
Next Steps for Production Readiness
For a complete evaluation before production, additional testing would include diverse customer profiles, edge cases, stress testing, security audits, and regulatory compliance validation.
By starting with tool call accuracy and expanding to these broader evaluations, we can build confidence in our agent's ability to handle real-world mortgage pre-approval workflows reliably and accurately.
Running agent and capturing tool calls...
Captured tool call: check_experian
Captured tool call: check_equifax
Captured tool call: check_transunion
==================================================
EXECUTION PLAN:
==================================================
I will use the tools to check the credit scores from all bureaus, update the customer record with credit info, send employment verification email to the employer's HR department, and write the final report.
==================================================
------------------------------
Executing: check_experian
Parameters: {
"name": "Michael Scott",
"ssn": "123-45-6789"
}
Result: {
"credit_score": 720,
"report_date": "2025-03-15"
}
------------------------------
Executing: check_equifax
Parameters: {
"name": "Michael Scott",
"ssn": "123-45-6789"
}
Result: {
"credit_score": 715,
"report_date": "2025-03-15"
}
------------------------------
Executing: check_transunion
Parameters: {
"name": "Michael Scott",
"ssn": "123-45-6789"
}
Result: {
"credit_score": 718,
"report_date": "2025-03-15"
}
Captured tool call: update_customer_record
------------------------------
Executing: update_customer_record
Parameters: {
"customer_id": "CUS20240111105523",
"credit_info": {
"experian": 720,
"equifax": 715,
"transunion": 718
}
}
Result: {
"status": "success",
"message": "Updated credit info for CUS20240111105523"
}
Captured tool call: send_employment_verification_email
------------------------------
Executing: send_employment_verification_email
Parameters: {
"employer_name": "Dunder Mifflin Paper Company",
"employee_name": "Michael Scott",
"employer_email": "hr@dundermifflin.com",
"salary": 95000.0
}
Result: {
"status": "sent",
"to": "hr@dundermifflin.com",
"verification_status": "PENDING"
}
Captured tool call: write_final_report
------------------------------
==================================================
Waiting for employer verification response...
==================================================
Agent execution complete.
Number of reference tool calls: 6
Number of actual tool calls: 6
Reference Tool Calls:
1. check_experian with args: {'name': 'Michael Scott', 'ssn': '123-45-6789'}
2. check_equifax with args: {'name': 'Michael Scott', 'ssn': '123-45-6789'}
3. check_transunion with args: {'name': 'Michael Scott', 'ssn': '123-45-6789'}
4. update_customer_record with args: {'customer_id': 'CUS20240111105523', 'credit_info': {'experian': 720, 'equifax': 715, 'transunion': 718}}
5. send_employment_verification_email with args: {'employer_name': 'Dunder Mifflin Paper Company', 'employee_name': 'Michael Scott', 'employer_email': 'hr@dundermifflin.com', 'salary': 95000.0}
6. write_final_report with args: {'customer_id': 'CUS20240111105523'}
Actual Tool Calls:
1. check_experian with args: {'name': 'Michael Scott', 'ssn': '123-45-6789'}
2. check_equifax with args: {'name': 'Michael Scott', 'ssn': '123-45-6789'}
3. check_transunion with args: {'name': 'Michael Scott', 'ssn': '123-45-6789'}
4. update_customer_record with args: {'customer_id': 'CUS20240111105523', 'credit_info': {'experian': 720, 'equifax': 715, 'transunion': 718}}
5. send_employment_verification_email with args: {'employer_name': 'Dunder Mifflin Paper Company', 'employee_name': 'Michael Scott', 'employer_email': 'hr@dundermifflin.com', 'salary': 95000.0}
6. write_final_report with args: {'customer_id': 'CUS20240111105523'}
Tool Call Accuracy Score: 1.0000
Evaluation Results Analysis
The evaluation results demonstrate our mortgage pre-approval agent executing the exact workflow we designed. The agent methodically processes credit checks from all three bureaus (Experian, Equifax, and TransUnion), updates the customer record with the collected information, sends the employment verification email with correct parameters, and prepares to write the final report. The perfect RAGAS Tool Call Accuracy score of 1.0 confirms that our agent is following the intended sequence with properly formatted parameters, validating our design decisions and implementation approach.
Module 6: Deploy to Production
While our notebook example can't be directly deployed, let's examine how a mortgage pre-approval agent would be implemented in a real financial institution.
Deployment Environments
A successful deployment requires three distinct environments. The development environment includes version control, CI/CD pipelines, and anonymized data for testing. A staging environment provides an isolated network with synthetic customer data for integration testing. The production environment consists of secure, redundant servers, a high-availability database cluster, and live API integrations.
Four-Week Pilot Rollout
Our deployment follows a gradual four-week pilot:
-
Week 1: Controlled Testing - Process 10 live applications daily with human loan officers confirming each decision. If unexpected behavior occurs, take the agent offline for further development.
-
Week 2: Limited Scale-Up - Handle 5-10% of loan applications with continued human confirmation, providing insight into performance under increased volume.
-
Week 3: Confidence Building - Expand to 25-30% of applications with reduced human review as confidence in the system grows.
-
Week 4: Full Implementation - Gradually scale to handling the majority of standard applications, routing only complex cases to human officers.
Security and Monitoring
Throughout deployment, we implement comprehensive security measures and monitoring. All sensitive customer data is encrypted, and we maintain audit trails of agent actions. Key performance metrics are tracked, including tool call accuracy, processing time, and error rates. Regular security reviews and compliance checks ensure the system meets all regulatory requirements.
By following this measured approach with appropriate human oversight, financial institutions can successfully deploy mortgage pre-approval agents that enhance efficiency while maintaining security, quality, and regulatory compliance.