
Module 10 Lesson 3: Creating a Simple Workflow
How do you go from a prompt to a real app? In our final lesson of Module 10, we learn how to link RAG, Tools, and Memory into a single cohesive AI Agent.
Module 10 Lesson 3: Creating a Simple Workflow
In the last two modules, we learned about individual skills: RAG for reading facts, and Tools for taking actions. But in the real world, you don't just use one. You use both in a specific sequence. This is called Orchestration.
In this lesson, we will build a conceptual "Travel Agent" workflow to see how these parts work together in a loop.
1. The Design of the Workflow
Imagine a user says: "I want to go to Paris. Do I have enough money in my budget for a 5-day trip?"
To answer this, the AI needs to:
- Retrieve Data (RAG): Read the user's private holiday budget document.
- Call a Tool: Call a flight API to get the current price of a ticket to Paris.
- Perform Logic: Subtract the flight cost from the budget and calculate if the remainder covers 5 days of hotels.
- Respond: Give the final "Yes" or "No" to the user.
2. Managing "State" and Memory
The biggest challenge in complex workflows is State. The model needs to remember what happened in Step 1 while it is doing Step 3.
- In professional apps, we don't just rely on the model's built-in context window. We often save these values in a Database and feed them back to the model as "Memory" for each new step.
3. The Multi-Step Loop
graph TD
User["User Query"] --> Step1["Step 1: RAG Search (User Data)"]
Step1 --> Step2["Step 2: Tool Call (Flight Prices)"]
Step2 --> Step3["Step 3: Reasoning (Math/Logic)"]
Step3 --> Step4["Step 4: Safety Check (Guardrails)"]
Step4 --> Final["Final Output to User"]
4. Why Frameworks (like LangChain or AutoGen) exist
Building these loops manually is difficult. Developers use Orchestration Frameworks to handle the "glue" between the steps. These frameworks:
- Automatically format the JSON for tool calls.
- Handle errors (e.g., if a tool fails, the AI is told to try again).
- Manage the conversation history so the context doesn't get cluttered.
Lesson Exercise
Goal: Build a logic flow.
You are building an AI "Tutor" for a math student.
- Step 1: The student asks a question.
- Step 2: The AI uses RAG to read the textbook to find the relevant formula.
- Step 3: The AI uses a Tool (Calculator) to verify the numbers.
- Step 4: The AI uses Prompt Engineering to explain the answer simply.
Challenge: What happens if the RAG search in Step 2 fails to find the formula? Write a "Fallover" instruction for the AI. (e.g., "If you can't find it, ask the student for its name.")
Summary
In this lesson, we established:
- Professional apps link multiple LLM capabilities (RAG, Tools, Memory) into workflows.
- Orchestration is the "glue" that ensures steps happen in the correct order.
- Frameworks help manage the complexity of multi-step AI agents.
Next Module: We face the reality check. In Module 11: Limitations of LLMs, we'll learn about what AI can't do, from long-horizon planning to understanding causality.