DEV Community

Amol
Amol

Posted on

Mortgage Policy & Guideline Agent — Sanity Challenge Path One

Sanity Challenge Path One Submission

This is a submission for the Sanity Challenge, Path One: Ship an Agent That Queries Real Content

What I Built

I built a Mortgage Policy & Guideline Agent that answers mortgage eligibility and policy questions using structured mortgage content stored in Sanity.

Mortgage policy questions can look simple but often depend on several connected pieces of information: loan-product limits, underwriting guidelines, exceptions, and the source supporting each rule.

Instead of relying only on an LLM's memory, I created a structured Sanity knowledge base containing:

  • Mortgage Policies
  • Guidelines
  • Loan Products
  • Exceptions
  • Sources and citations

The agent can retrieve the relevant structured content before answering a question.

For example, a conventional mortgage decision can depend on:

  • Minimum credit score
  • Maximum DTI
  • Maximum LTV
  • Loan purpose
  • Occupancy
  • Applicable guideline
  • Documented exceptions
  • Exception conditions
  • Supporting source

The goal is to make the answer traceable back to structured content rather than simply producing a plausible AI response.

Demo

Live Application

Mortgage Policy & Guideline Agent

The companion web application provides a simple interface for asking mortgage questions and viewing:

  • Eligibility results
  • Important rules
  • Borrower and product facts
  • Source citations
  • Sanity-backed responses

Try These Prompts

1. Eligibility

Conventional purchase, 640 credit score, 47% DTI and 95% LTV. Is the borrower eligible? Explain the rules that determine the answer.

2. Product Comparison

Compare the Harborstone 30-year and 15-year conventional products. What are the differences in minimum credit score, maximum DTI and maximum LTV?

3. Exception Reasoning

A conventional borrower has a DTI above the standard limit. What documented exceptions could apply, and what conditions must be satisfied?

4. Source Verification

What source and effective date support the maximum DTI rule for the Harborstone conventional product?

5. Scenario Change

A borrower has 700 credit, 47% DTI and 95% LTV. Does the answer change compared with a borrower with 640 credit? Explain why.

6. Explain the Decision

Don't just tell me whether this borrower qualifies. Walk through credit score, DTI, LTV, applicable guideline, exception eligibility and supporting source.

The Harborstone mortgage catalog is fictional demo data created for this project and is not official lending guidance.

Code

GitHub — Mortgage Policy & Guideline Agent

The repository contains the Sanity schemas, structured demo content, GROQ queries, agent instructions, MCP configuration, and companion web application.

How I Used Sanity

The core of the project is the structured mortgage knowledge base in Sanity.

I modeled mortgage information as connected content rather than a single collection of unstructured documents.

The main content types are:

Loan Products

Products contain structured underwriting limits such as:

  • Minimum credit score
  • Maximum DTI
  • Maximum LTV
  • Minimum down payment
  • Loan type
  • Occupancy
  • Loan purpose
  • Product code

Guidelines

Guidelines contain structured thresholds such as:

  • Metric
  • Operator
  • Value
  • Unit

For example, a guideline can represent a DTI threshold such as DTI <= 45%.

Exceptions

Exceptions contain:

  • Conditions
  • Compensating factors
  • Approval requirements
  • Exception identifiers
  • Relationships to applicable guidelines

Sources

Sources provide the supporting information used for citations, including:

  • Source title
  • Published/effective date
  • Locator
  • Excerpt
  • URL where applicable

This structure allows the agent to retrieve the information needed to answer a question instead of treating mortgage policy as plain text.

Sanity Context MCP

I connected my Cursor AI agent to Sanity Context MCP for the Path One implementation.

The agent uses Sanity Context MCP to query the live Sanity dataset and retrieve the structured mortgage content.

The flow is:

User question

Cursor AI agent

Sanity Context MCP

Sanity Project krg1w0kt / production

Structured mortgage content

Product + Guideline + Exception + Source

Grounded answer with supporting information

The MCP tools used by the agent include document querying and retrieval through the Sanity Context MCP connection.

I also created project-specific Cursor rules and a mortgage-policy-agent skill that instruct the agent to use Sanity content when answering mortgage policy questions and to provide citations.

Why structured content matters

Consider this question:

Conventional purchase, 640 credit score, 47% DTI and 95% LTV. Is the borrower eligible?

The agent needs more than a keyword match.

It needs to identify the relevant conventional product, retrieve the applicable DTI and credit thresholds, check the borrower's values against those thresholds, and determine whether a documented exception applies.

That is where the structured Sanity content becomes important.

The same Sanity dataset is also used by the companion web application, which provides a user-friendly interface for the mortgage agent.

Sanity Project Details

Project ID: krg1w0kt

Dataset: production

The Sanity project contains the structured mortgage knowledge base used by the agent.

The primary document types are:

  • Mortgage Policy
  • Guideline
  • Loan Product
  • Exception
  • Source

The project ID is provided so the Sanity team can inspect how the content was modeled and used.

Agent Session

The Path One agent was developed and tested in Cursor using Sanity Context MCP.

An agent-session transcript is optional for this submission. If included, it will be curated to show the relevant parts of the development process and Sanity MCP interaction.

Any published transcript will be checked for API keys, tokens, credentials, or other sensitive information before publication.

sanitychallenge

Top comments (0)