DEV Community

Nabil Thange
Nabil Thange

Posted on

I built an AI tutor with persistent memory in 6 hours — here's how

I built an AI tutor with persistent memory in 6 hours — here's how

Every study app I've used has the same problem.

Open it on Monday. It helps you. Close it.

Open it on Thursday. It has no idea who you are.

Same generic suggestions. Same random quiz topics. No memory of the fact that you failed recursion questions three times this week.

So for this hackathon — theme: AI Agents That Learn Using Hindsight — we built Sage. An AI tutor that actually remembers you.


What Sage does

You upload your syllabus PDF. Sage reads it, extracts every subject and chapter, and asks you what you already know. Then it generates a personalised study plan built around your actual weak areas — not a template.

Every time you:

  • Take a quiz and get something wrong
  • Ask the AI to re-explain a concept
  • Tell the planner you have an exam coming up
  • Finish a Pomodoro session

...Sage writes that to memory. Forever.

Come back three days later? The AI opens with:

"Welcome back. Last session you struggled with VSWR. Your IOT exam is in 4 days. Want to pick up from there?"

That's not a chat history trick. That's a persistent memory system.


The tech that makes it possible — Hindsight

The memory layer is powered by Hindsight by Vectorize.

Hindsight isn't just a key-value store. When you call retain(), it uses an LLM internally to extract facts, entities, and temporal data — then classifies them into 4 memory types:

  • World — objective facts ("IOT exam is March 28")
  • Experiences — what actually happened ("scored 4/10 on quiz, failed VSWR")
  • Observations — patterns it auto-synthesises ("user consistently fails application questions")
  • Opinions — beliefs with confidence scores ("needs more practice: 0.91 confidence")

And reflect() reasons across all of these to generate insights like:

"Strong in theory. Consistently weak in numerical and application problems."

This is what makes Sage feel like a real tutor — not just a chatbot.


Architecture

User → Next.js frontend
         ↓
/api/planner/chat   → recall() from Hindsight → Groq with memory context
/api/mentor/chat    → recall() + syllabus text → Groq → personalised teaching
/api/memory/retain  → Hindsight retain() on every meaningful interaction
/api/memory/reflect → Hindsight reflect() for insights + Memory Panel
Enter fullscreen mode Exit fullscreen mode

Stack:

  • Next.js 14 (App Router)
  • Groq — qwen3-32b, fast and free tier
  • Hindsight Cloud — persistent per-user memory banks
  • shadcn/ui + Tailwind — dark-themed component library
  • pdf-parse — server-side syllabus extraction

The Memory Panel — making invisible AI visible

The coolest thing we built wasn't the chat. It was the 🧠 Memory Panel.

One click and you see everything the AI knows about you — grouped by type, with confidence scores on opinions, and a live reflect() summary at the top:

🌍 World
   BTech CSE Sem 3. IOT exam March 28.

🎯 Experiences
   Scored 4/10 on IOT quiz. Failed: VSWR, antenna gain.

🔍 Observations (auto-synthesised)
   Fails application questions consistently across 3 sessions.

💭 Opinions
   Needs IOT application practice — 0.91 confidence
Enter fullscreen mode Exit fullscreen mode

This screen alone makes it obvious that the AI is actually learning — not just replying to prompts.


What we learned

1. Hindsight's reflect() is the killer feature. It's not retrieval — it's synthesis. The AI forming its own opinions about a student's learning patterns is something no RAG pipeline gives you.

2. Build memory-first, UI second. We wired Hindsight in the first hour. Every feature we built after that automatically had memory context. If you add memory last, you have to retrofit everything.

3. The "return visit" moment is your demo. Log out, log back in, watch the AI greet you with context from days ago. That's the moment that makes people go "wait, this is actually different."


What's next for Sage

  • NotebookLM MCP integration for Studio outputs (audio overview, infographic, slide deck)
  • Real Supabase persistence for test history and proficiency tracking
  • Smarter pre-test adaptive questioning

Built in 6 hours at a hackathon. Theme: AI Agents That Learn Using Hindsight.

If you're building anything with persistent AI memory — check out Hindsight. It's genuinely different from standard RAG.

Code dropping soon. Follow for updates.


Top comments (0)