DEV Community

Sayed Khasim pasha
Sayed Khasim pasha

Posted on

AI coding mentor

My agent warns me before I repeat bugs

“⚡ You made this mistake before!”

That message popped up while I was debugging a simple Python loop—and it genuinely surprised me. I wasn’t using a better model or smarter prompts. I had just added memory.

This project is an AI Coding Mentor built with Streamlit that helps users write, run, and debug code. But the interesting part isn’t code execution or explanations—it’s the ability to remember past mistakes and use them to improve future interactions.


What I built

I built a coding assistant that:

  • Lets users write code in multiple languages
  • Executes Python code in real time
  • Explains errors using AI
  • Remembers past mistakes
  • Warns users when they repeat the same errors

The system is built using:

  • Streamlit (UI)
  • Groq API (AI explanations)
  • A custom memory system (inspired by Hindsight)

The problem: AI forgets everything

Most coding assistants behave like this:

  • You make a mistake
  • It explains the error
  • You fix it
  • It forgets everything

So what happens?

👉 Users repeat the same mistakes again and again

👉 The assistant gives the same explanation again

👉 No real learning happens

I wanted to change that.


Adding memory (Inspired by Hindsight)

Instead of treating each error independently, I added a memory layer.

Learn more about the concept here:

Now, whenever an error occurs, I store:

  • The code
  • The error message
  • The suggested fix

python
st.session_state.history.append((code, err, fix))
Enter fullscreen mode Exit fullscreen mode

Top comments (0)