top of page

Build a Multi-Agent AI Personal Learning Assistant Using LangGraph

  • Writer: Nagesh Singh Chauhan
    Nagesh Singh Chauhan
  • Jun 26
  • 10 min read

How eight specialised AI agents, two LangGraph state machines, a Tavily MCP search pipeline, and the 40-year-old SM-2 memory algorithm combine to create a tutor that gets smarter every session.




Before I begin here is the Github repository: Forge


I have also recorded a video for demonstration of the application and usage. 👇



Introduction


The way we learn has always been shaped by the tools available to us — from textbooks and classrooms to MOOCs and YouTube tutorials. Yet despite decades of innovation, most learning tools still share a fundamental limitation: they are static. They deliver the same content to every learner, at the same pace, in the same sequence, regardless of what you already know, how fast you're progressing, or what you're about to forget.


Large language models changed the conversation. For the first time, it became possible to have a system that could explain concepts, answer follow-up questions, generate examples on demand, and adapt its tone to the learner. But a single LLM, no matter how capable, is still a generalist — and teaching is not a single job. Designing a curriculum, generating assessments, discovering resources, scheduling reviews, tracking performance, and coaching a learner through frustration are fundamentally different tasks that require different logic, different prompting strategies, and in some cases, no language model at all.


This is the problem that multi-agent architecture solves.


In this article, we build Forge (I liked the name :p) — a production-ready, multi-agent AI personal learning assistant — from the ground up. Rather than wiring a single model to a chat interface, we decompose the entire learning lifecycle into eight specialised agents, each owning exactly one responsibility, all coordinated by a central Coach Agent backed by a LangGraph state machine. The Quiz Agent adapts difficulty based on your past scores.


The Resource Agent performs live web search via Tavily MCP and re-ranks results by your learning style. The Revision Agent implements the SM-2 spaced repetition algorithm — the same science that powers Anki — to schedule every topic's next review date based on demonstrated recall. The Performance Agent detects plateaus and knowledge decay before you feel them.


By the end of this article, you will understand not just how to build each agent, but why the boundaries between them exist, how LangGraph turns a collection of agents into a coherent workflow, how the Model Context Protocol connects your system to live external tools, and how a 40-year-old memory algorithm quietly does the most important work of all — ensuring that what you learn today is still there six weeks from now.


The Problem with Monolithic AI Tutors


Every major AI tutoring product shares the same architectural flaw: a single language model trying to simultaneously be a curriculum designer, quiz engine, resource librarian, performance analyst, and motivational coach. This produces what engineers call a generalist bottleneck — a system where every capability competes for the same context window, the same temperature setting, and the same reasoning chain.


The consequences are predictable. The "tutor" gives you the same resources regardless of whether you learn best by watching videos or reading documentation. It generates the same quiz difficulty whether you just scored 95% or 40% on the last session. It has no memory of what you studied two weeks ago, so it never knows what you are about to forget.



Forge solves this by decomposing the learning lifecycle into eight discrete agents, each owning exactly one domain, all coordinated by a LangGraph state machine. This is not "agents for the sake of agents" — each boundary exists because the tasks on either side require meaningfully different logic, prompting strategies, and in some cases, no LLM at all.




Forge at a Glance — Architecture Overview


The top-level structure is a hub-and-spoke model. The Coach Agent sits at the centre, owning both LangGraph state machines. Every specialised agent radiates outward from it. Crucially, there are no direct calls between specialised agents — the Coach Agent is the only coordinator. This keeps dependency graphs linear and failures local.


Forge multi-agent architecture. The Coach Agent (top, blue) is the sole coordinator. All eight specialised agents communicate exclusively through typed return values and the shared LearnerProfile model.
Forge multi-agent architecture. The Coach Agent (top, blue) is the sole coordinator. All eight specialised agents communicate exclusively through typed return values and the shared LearnerProfile model.



Project Structure





The Shared Data Contract: LearnerProfile


Before examining any individual agent, it is worth understanding what they all share. Every agent in Forge reads from and writes to a central LearnerProfile Pydantic model. This is not a global mutable dictionary — it is a typed, validated schema that enforces the contract between agents at runtime.



The supporting models are equally precise:




LangGraph: Orchestrating Agents with State Machines


LangGraph is a library built on top of LangChain that lets you define stateful, multi-step agent workflows as directed graphs. Each node in the graph is a Python function that receives the current state, does work, and returns an updated state. Edges define the execution order. LangGraph handles state threading, error propagation, and graph compilation automatically.


Forge compiles two separate LangGraph state graphs. Each is a deterministic sequence of nodes — no conditional branching, no loops. The predictability is intentional: you can read the code and know exactly what will happen in every session.


The State Schema



The two LangGraph state machines. Graph 1 (left) prepares a learning session across three nodes. Graph 2 (right) runs the full post-quiz analysis pipeline in a single node. State flows linearly — no branching.
The two LangGraph state machines. Graph 1 (left) prepares a learning session across three nodes. Graph 2 (right) runs the full post-quiz analysis pipeline in a single node. State flows linearly — no branching.

Graph 1 — Session Preparation: START → assess → resources → quiz → END


The assess node is where session intelligence lives. It checks the SM-2 revision queue first — if any topics are overdue, the session switches to revision mode. Only when nothing is overdue does it advance the curriculum, respecting dependency edges:



The resources node calls the Resource Agent (Tavily MCP + LLM ranking). The quiz node calls the Quiz Agent (10 adaptive questions). Both are pure functions — deterministic given the same state.


Graph 2 — Session Analysis: START → analyze → END


After the learner completes the quiz, the analyze node runs seven sequential operations in a single pass — all inside one LangGraph node, meaning the entire post-session pipeline is atomic:



Why Two Graphs, Not One?


Separating preparation from analysis keeps each graph's concern clean. The session preparation graph runs before the learner sees any content — it must be fast and cannot depend on quiz results. The analysis graph runs after — it has full quiz data and needs to write back to the profile. Combining them would force the graph to carry uncommitted state between user interactions, complicating state management significantly.


The Eight Specialised Agents



Adaptive Difficulty in Detail


The Quiz Agent's difficulty inference is simple but effective. It reads past quiz scores for the current topic, computes a rolling average, and sets the question difficulty level for the LLM prompt accordingly:



The difficulty integer then feeds directly into the generation prompt as both a numeric value and a human label ("beginner", "advanced", etc.), and the learner's weak spots are listed explicitly so the LLM can target them in scenario-based questions.


Left: LLM temperature per agent — colour-coded by purpose (purple=deterministic, yellow=generative, green=conversational). Right: Agent capability matrix showing which agents use LLMs, Pydantic models, LangGraph nodes, SM-2, external APIs, and local scoring.
Left: LLM temperature per agent — colour-coded by purpose (purple=deterministic, yellow=generative, green=conversational). Right: Agent capability matrix showing which agents use LLMs, Pydantic models, LangGraph nodes, SM-2, external APIs, and local scoring.

Tavily MCP: Live Resource Discovery


Most AI learning tools surface the same static, pre-curated resources regardless of what the learner already knows or how they learn best. Forge's Resource Agent takes a fundamentally different approach: it performs live web search at the start of every session, tailoring queries to the learner's demonstrated style and filtering out material they have already seen.


The mechanism is Tavily MCP — Tavily's search API exposed via the Model Context Protocol (MCP). MCP is an open standard that allows AI models to invoke external tools via a structured protocol, much like a typed function call. Rather than scraping search results inside a prompt, the agent makes a proper API call and receives structured data back.


The Resource Agent's 5-stage discovery pipeline. Tavily MCP (Stage 1) performs live web search; YouTube search adds video resources (Stage 2); an LLM re-ranks by learner style (Stage 3); already-seen URLs are filtered out (Stage 4); the top 6 resources are returned (Stage 5). If MCP is unavailable, the agent falls back to heuristic suggestions.
The Resource Agent's 5-stage discovery pipeline. Tavily MCP (Stage 1) performs live web search; YouTube search adds video resources (Stage 2); an LLM re-ranks by learner style (Stage 3); already-seen URLs are filtered out (Stage 4); the top 6 resources are returned (Stage 5). If MCP is unavailable, the agent falls back to heuristic suggestions.

Learning Style Modifiers


The search queries are not generic. The Resource Agent injects style-specific modifier terms before sending queries to Tavily, ensuring that a visual learner receives diagrams and video tutorials while a reading/writing learner receives articles and documentation:

Learning Style

Search Modifier Injected

Result Type

Visual

tutorial video diagram infographic

YouTube videos, visual guides

Auditory

podcast lecture audio explanation

Podcasts, recorded lectures

Reading/Writing

article guide documentation deep-dive

Blog posts, official docs

Kinesthetic

hands-on project exercise practice lab

Tutorials, coding exercises


Graceful Degradation


Network failures and API outages are facts of production life. If the Tavily MCP call fails, the Resource Agent does not crash the session or return an error to the learner. Instead, it falls back to an LLM call that generates six well-known resource suggestions using platform heuristics (official documentation, popular courses, reputable tutorials). The learner never sees the failure.


SM-2: The Science of Long-Term Memory


Generating good explanations and quizzes is the easy part of an AI tutor. The hard part — and the part most products ignore — is ensuring that knowledge persists over weeks and months. Without a scheduling mechanism, a learner who masters a topic in week one will have forgotten most of it by week four, whether or not an AI told them they were "doing great."


Forge solves this with the SM-2 algorithm (SuperMemo 2), developed by Piotr Woźniak in 1987. SM-2 is one of the most empirically validated algorithms in cognitive science — it underpins Anki, the most widely used spaced repetition software in the world. Its core insight: the optimal time to review information is just before you would forget it, and that interval grows exponentially with each successful recall.


The Three Core Functions



score_to_quality is the bridge between the AI and cognitive science worlds. It translates a continuous quiz score into the discrete quality signal that SM-2 expects. This is the integration point that makes the whole system coherent — AI evaluation feeding a memory algorithm built decades before neural networks existed.


Left: Review interval growth by learner performance type. An ace learner's review intervals grow exponentially (green), reaching months between sessions. A struggling learner stays in short cycles (orange dashes) until scores improve. Right: The score-to-quality-to-interval mapping — a quiz score drives the quality signal which determines the next review date.
Left: Review interval growth by learner performance type. An ace learner's review intervals grow exponentially (green), reaching months between sessions. A struggling learner stays in short cycles (orange dashes) until scores improve. Right: The score-to-quality-to-interval mapping — a quiz score drives the quality signal which determines the next review date.

Left: Cumulative study timeline across three learning phases. Phase 1 (initial encoding) and Phase 2 (consolidation) are short and fixed. Phase 3 (long-term retention) grows exponentially — an ace learner reviews the same topic 8 times over more than 400 cumulative days. Right: Ease factor evolution — quality 5 learners see EF grow past 3.0 (very long gaps); quality 2 learners are clamped at the 1.3 floor.
Left: Cumulative study timeline across three learning phases. Phase 1 (initial encoding) and Phase 2 (consolidation) are short and fixed. Phase 3 (long-term retention) grows exponentially — an ace learner reviews the same topic 8 times over more than 400 cumulative days. Right: Ease factor evolution — quality 5 learners see EF grow past 3.0 (very long gaps); quality 2 learners are clamped at the 1.3 floor.

The Three Phases of Learning


Phase

Interval

Description

1 — Initial

0 → 1 day

First exposure. Review the next day regardless of score.

2 — Consolidation

1 → 6 days

First recall test. Still in short cycle — building the memory trace.

3 — Retention

6 → 6×EF → … (exponential)

Intervals grow with each successful review. Ease factor drives the multiplier.


The Mastery Trap — And How Forge Avoids It


Most learning platforms mark a topic "complete" and never revisit it. This is a mistake grounded in a misunderstanding of how memory works. Completion is not permanence — knowledge decays on a well-studied curve, and topics that felt effortless in week one will be hazy by week six without reinforcement.


Forge marks topics complete at 70% (removing them from the active curriculum) but continues scheduling them in the SM-2 queue indefinitely. The Performance Agent also flags "knowledge decay" — topics in the learner's strength list that have not been reviewed in 14 or more days. Completion is a checkpoint, not an exit.




Conversational Intelligence: Chat & Socratic Modes


Beyond structured sessions, the Coach Agent exposes two conversational interfaces that let learners interact freely — but both are grounded in the learner's full history, not generic knowledge.


Coach Chat Mode


In chat mode, the system prompt is populated with the learner's complete profile on every turn: progress percentage, streak, total hours, strengths, weak spots, overdue revision count, and the Performance Agent's latest insight and recommendation. The LLM is never flying blind:



The coach's instructions are equally specific: "You never give generic advice — every response is tailored to this learner's history." If you ask "how am I doing?", the system tells you that your Transformer Architecture score has plateaued across three sessions and your last review of Attention Mechanisms was 19 days ago.


Socratic Mode


Socratic mode enforces a strict conversational protocol backed by decades of educational research: the coach never gives direct answers, asks exactly one probing question per turn, and escalates depth systematically — from recall (turn 1–2) to application (turn 3–5) to synthesis (turn 6+):




Temperature as a Design Dimension


One of the subtler but more consequential architectural choices in Forge is treating LLM temperature as a per-agent parameter rather than a global setting. Temperature controls how much creative variance the model introduces — and different agent tasks have very different tolerance for variance.


A quiz generator that hallucinates plausible-but-incorrect "correct answers" due to high temperature is actively harmful. A coach that gives robotically identical motivational messages due to low temperature is useless. These are not edge cases — they are the central failure modes of AI tutoring systems.


Temperature

Agent

Task Type

Why This Setting

0.3

Plan Agent

Curriculum design

Deterministic ordering, reproducible dependency graphs

0.3

Resource Agent

Search + ranking

Consistent relevance scoring; style modifiers do the creative work

0.4

Performance Agent

Narrative generation

Stats are pre-computed locally; LLM only writes the 2-sentence summary

0.4

Scenario Agent (eval)

Rubric scoring

Evaluation must be consistent across attempts

0.5

Quiz Agent

Question generation

Variety without hallucinating wrong "correct answers"

0.5

Flashcard Agent

Card generation

Variety in phrasing; accuracy still required

0.65

Scenario Agent (gen)

Case study generation

Narrative richness; company/crisis details benefit from creativity

0.7

Coach Agent (chat)

Conversational coaching

Natural, non-repetitive dialogue; warmth requires variance

0.7

Coach Agent (Socratic)

Socratic questioning

Question variety essential; repetitive probing defeats the purpose


End-to-End Session Data Flow


Understanding the system requires seeing all three phases of a learner's journey: onboarding (curriculum creation), the learning session (preparation and execution), and post-session analysis (memory scheduling and feedback). Each phase hands off cleanly to the next through the shared LearnerProfile.


Complete session data flow across three phases. Phase 1 (Onboarding) builds the curriculum asynchronously. Phase 2 (Learning Session) runs Graph 1 to prepare content, then scores the quiz locally. Phase 3 (Analysis) runs Graph 2 to update SM-2, strengths, streak, and generate the coach message — all atomically before persisting to SQLite.
Complete session data flow across three phases. Phase 1 (Onboarding) builds the curriculum asynchronously. Phase 2 (Learning Session) runs Graph 1 to prepare content, then scores the quiz locally. Phase 3 (Analysis) runs Graph 2 to update SM-2, strengths, streak, and generate the coach message — all atomically before persisting to SQLite.


Key Dependencies

Library

Role in Forge

State machine orchestration for multi-step agent flows

LLM abstractions, message types (SystemMessage, HumanMessage), prompt chaining

LLM backend via AzureChatOpenAI for all agents

Reactive web UI with param-based state management

Data models, validation, JSON serialisation between agents

Live web search via Model Context Protocol

Zero-config local persistence for learner profiles

Interactive progress charts in the dashboard


Conclusion


Forge demonstrates that building effective AI-powered learning systems is not about relying on a single, all-capable LLM—it is about designing a well-orchestrated system of specialized agents, each responsible for a specific task.


The architecture highlights five key principles: modular single-responsibility agents that are easier to test and maintain; maximizing local computation to reduce cost, latency, and non-determinism; clean, structured integration with external tools through MCP; long-term knowledge retention powered by the proven SM-2 spaced repetition algorithm; and task-specific model configurations where parameters such as temperature are intentionally chosen rather than treated as generic defaults.


Together, these design decisions create a learning platform that is accurate, scalable, cost-efficient, and maintainable. More importantly, Forge illustrates a broader lesson for agentic AI systems: success comes not from making one model smarter, but from enabling multiple specialized components to collaborate effectively.

Comments


Follow

  • Facebook
  • Linkedin
  • Instagram
  • Twitter
Sphere on Spiral Stairs

©2026 by Intelligent Machines

bottom of page