DEV Community

Liam Steiner
Liam Steiner

Posted on

My AI study sessions kept starting from zero — so I built persistent memory into the assistant

I study physics in whatever gaps exist in my day. Twenty minutes before work, an hour on a good evening. Sessions are short and scattered.

The problem wasn't the AI — it was the re-onboarding. Every session I'd spend the first ten minutes re-explaining where I was: what topic, what notation
we'd agreed on, what I was stuck on last time. Half the session gone before asking anything useful.

So I built a memory layer. Every conversation gets indexed into a local sqlite-vec database with Gemini embeddings. When a new session starts, it queries semantically for relevant past context:

q_vec = embed(query)
  rows = db.execute(
      """
      SELECT e.path, e.date, e.tldr, e.topics, v.distance
      FROM embeddings v
      JOIN entries e ON e.id = v.rowid
      WHERE v.embedding MATCH ? AND k = ?
      ORDER BY v.distance
      """,
      [serialize(q_vec), top * 6],
  ).fetchall()
Enter fullscreen mode Exit fullscreen mode

The difference in practice: I ask about the Euler-Lagrange equation and it already knows we spent three sessions on constrained systems last week, that I
keep mixing up generalized coordinates, and that we're using Goldstein as the reference. I don't say any of that — it just knows.

But it's not limited to study sessions.
Last week I asked it what movie my roommate and I could watch together. It knew both our tastes from past conversations and gave a recommendation that actually made sense.
That's when it clicked for me — it doesn't just remember topics, it remembers you.

Everything runs locally — no cloud memory store, no third-party seeing your conversations.
Open source if you want to dig in: github.com/sliamh11/Deus

Top comments (0)