By Priyanshu | Team Clarion | Code Mentor AI
"All six of us had the same experience — failing a loop problem on LeetCode, getting the same unhelpful hint, and coming back the next week to fail it again. The platform had no memory of us. I wanted to build the feature that changes that most viscerally: the one that shows you, in real time, that you have been here before."
Context-Aware Debugging: The Feature
When a student hits an error in Code Mentor AI, Context-Aware Debugging kicks in. It takes the current code and error, generates a CodeBERT embedding, runs a cosine similarity search over the student's entire mistake history in PostgreSQL, and returns the top-3 most similar past mistakes usually within a second.
The student sees a panel that says: 'You've seen something like this before.' With links to the exact past mistakes, the code they wrote then, and what the error was.
The Vector Search
The similarity search is powered by pgvector. Every mistake in Hindsight has a 768-dimensional CodeBERT embedding stored in a vector column. At debug time:
The <=> operator is pgvector's cosine distance. The query is fast because we index the vector column with an IVFFlat index. At hackathon scale this wasn't strictly necessary, but it meant the feature felt instant.
Dynamic AI Assistance
Beyond context-aware debugging, I also worked on the dynamic AI assistance layer the part that decides, based on the student's current state and history, which AI feature should activate and with what parameters. A student on their first mistake gets a different response than one who has made this exact mistake three times.
The Moment That Stopped Us
During testing, a student profile triggered context-aware debugging on a recursion problem. The system surfaced a mistake from three sessions back one the student had only made once. The similarity score was high even though it was a rare mistake, because the code structure was genuinely similar. The panel message: 'You've seen this before three sessions ago, same structure, different function.' Nobody on the team had explicitly programmed that. The vector math found it.
The Lesson
Embeddings are better at finding structural similarity in code than keyword search ever could be. A student who writes while (i < n) and later writes while (left <= right) is making structurally similar mistakes even though the variable names are completely different. CodeBERT catches that. A text search doesn't.
The whole system is powered by Hindsight for agent memory. The Hindsight docs explain the retain/recall model that makes this kind of retrieval clean to implement.
Team Clarion
• Aanchal & Pranati — Backend architecture & database
• Lakshay — Full frontend integration with Next.js
• Aman, Kinjal & Priyanshu — Dynamic AI models & AI assistance features
Top comments (0)