Overview

2 Working with ADPs: Building a mortgage advisor tool

This chapter uses a mortgage advisor as a practical example for assembling agent design patterns into a reliable, regulated, and tool-using system. Mortgage advice is a strong case study because the agent must ask targeted questions, rely on specialized and time-sensitive knowledge, perform accurate long-term calculations, and avoid producing language that could violate financial regulations. Rather than treating the problem as a single conversational workflow, the design breaks the task into distinct stages that can be composed cleanly.

The overall flow begins with an information-gathering phase, where an interlocutor actively collects the missing details needed for the user’s request and stores them in structured form. Once enough information is available, a supervised team of specialist analysts takes over: each analyst is implemented as a ReAct-style agent with access to relevant tools, and a supervisor coordinates them to produce an aggregate analysis. The chapter emphasizes that this division into subagents helps manage complexity, keeps contexts smaller, and makes each specialist easier to improve and test independently.

After the analysis is complete, a reporting component turns the results into a user-facing mortgage advisory draft, and a compliance guardrail checks whether the language is acceptable under financial regulations. If the report fails compliance, feedback is fed back into the writing step so the system can refine the output, with retries capped to prevent endless looping. The result is a modular agent architecture in which runtime, orchestration, analysis, writing, and safety checks are separated but coordinated through shared state, showing how ADPs can support dependable agent behavior end to end.

Summary

  • Agent operations can be visualized using the agent flow diagrams (AFDs) introduced in this chapter.
  • To implement an agent like our example Mortgage Advisor agent, we compose high-level patterns to cleanly isolate the individual pieces of its functional logic.
  • It can be advantageous to use a variety of patterns in a single application, from the human-in-the-loop interlocutor, through a simple centralized team of (sub)agents, to a refiner and guardrails. These patterns all contribute to the user experience and agent-response quality in different ways.
  • One component of an agent’s implementation may have the characteristics of multiple patterns when appropriate. Although our MA example implementations are simple, the components implementing each pattern can be considerably more complex while still satisfying the same defining characteristics.

FAQ

What is the main goal of the mortgage advisor agent in this chapter?The mortgage advisor is designed to help users with mortgage-related decisions by gathering the right information, running specialized analyses, producing a report, and checking that the final output is compliant and reliable.
Why can’t a general-purpose chatbot with search access be enough for mortgage advice?Mortgage advice depends on specialized, time-sensitive knowledge, accurate calculations, and regulatory compliance. A general chatbot may ask the wrong questions, use outdated information, or produce unreliable financial reasoning.
What are the main stages of the mortgage advisor flow?The flow has three main stages: initial information gathering with an Interlocutor, analysis by a Team of ReAct analysts, and report writing followed by compliance checking and possible refinement.
What is an Agent Flow Diagram (AFD)?An AFD is a diagram style used to visualize agent behavior. It represents agent components as nodes and arrows, helping show deterministic steps, parallel processes, and loops in agent execution.
What does the Interlocutor pattern do in this mortgage advisor?The Interlocutor proactively asks the user for missing details until enough information has been collected to move forward. It acts like a conversational form that fills in required fields through dialogue.
Why is the analysis stage implemented as a Team of ReAct agents?The mortgage problem is too broad and context-heavy for one linear workflow. A team of specialized ReAct agents divides the work into subtasks so each analyst can focus on one aspect, such as rate fairness or income sufficiency.
What is the role of the supervisor in the analyst team?The supervisor coordinates the specialized analysts and treats them like tools. It orchestrates which subagents are called, combines their outputs, and produces the overall analysis response.
What is an Errand in this chapter?An Errand is a simple LM call, or a short sequence of LM calls with deterministic processing, used for straightforward tasks like writing the mortgage report. It does not involve iterative reasoning or tool use like a ReAct agent.
How does the compliance guardrail work?The compliance guardrail checks whether the report is acceptable under mortgage regulations. It returns a verdict such as pass or fail, along with feedback that can be used to improve the report if needed.
What happens if the report fails compliance checks?If the report fails, the feedback is stored and fed back into the report-writing step. The system retries up to three times, and if it still cannot produce a compliant report, the agent ends in failure.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Agent Design Patterns ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Agent Design Patterns ebook for free