AI teaching assistant
About this agent
A Telegram bot that gives a teacher persistent, contextual memory of every student. It covers three pieces: a Doubt Resolver that calibrates hints to what is actually known about a student, a student performance memory that compounds over time, and a Teacher Inbox / escalation queue that keeps a human in the loop. Every question passes a distress/bullying/non-academic safety classifier before anything else runs; a flag, or the classifier itself failing, routes straight to the teacher with no AI response shown to the student โ it fails safe, not open. Low-confidence hints are held as drafts for teacher approval rather than sent; image-based doubts are queued to the teacher untouched, since OCR extraction was deliberately left unbuilt rather than guessed at. Student and topic memory is fetched with explicit tag filters, never zenmem's automatic passMemory fetch, so one student's profile can never blend into another's hint.
What changed with Zenmem?
The same agent, built twice against the same contract โ once on Zenmem, once on MongoDB + LangChain/LangGraph.
Before โ after
Before With Zenmem
What the team gained
- One teacher's classroom is a single project scope with student and topic tags, so a per-student profile does not need a scope per child.
- Project-scope reads always go through explicit tag filters rather than automatic memory injection, which is what makes it structurally impossible for one student's profile to colour another's hint.
- Automatic injection is used only at session scope, where isolation to one doubt-thread is exact.
- A resolved-answer bank accumulates in the same scope the hints are drafted from, so a repeated question is answered from what already worked.
- A follow-up in the same thread sees the earlier hint because the thread is the session, not a conversation table to maintain.
How memory is scoped
Project scope holds everything long-lived: student profile notes and a resolved-answer bank, tagged with student_id or topic so a single teacher's classroom-wide memory pool can still be addressed per student or per subject. Session scope covers one doubt-thread โ one question and its hint โ started when a student asks and ended once it is resolved, so a follow-up "I'm still stuck" sees the earlier hint without leaking into any other student's thread. Automatic memory injection (passMemory=True) is only used at session scope, where isolation is exact; project-scope reads always go through explicit tag filters instead, because that scope is shared across every student in the classroom.
How it works
The doubt-resolution pipeline, question to reply.
Safety gate
Every text question is checked for distress, bullying or non-academic content before anything else; a flag, or the check itself failing, escalates straight to the teacher.
Gather context
Tag-filtered fetches pull this student's own profile notes and any previously teacher-approved answer on the same topic โ never a blended, untagged fetch.
Generate a scoped hint
A session opened per doubt-thread; an LLM call drafts a hint plus a self-reported confidence score, calibrated to what is known about the student.
Confidence gate
Hints at or above the configured threshold auto-send and close the thread; lower-confidence hints and all image-based doubts hold for teacher review.
Teacher inbox loop
The teacher approves, edits, or rejects via inline buttons; whichever path, the final answer is banked for reuse and a profile note is recorded.
Commands
What a student or teacher can do in the chat.
Commands
- /start โ registers the sender as a student, or as the teacher if their Telegram ID matches the configured teacher account.
- /inbox โ teacher-only: lists every pending escalation as a card, with a status label and Approve / Edit / Reject buttons where applicable.
- Any text message from a student runs the full doubt-resolver pipeline: safety check, context fetch, hint generation, confidence gate.
- Any photo from a student is queued straight to the teacher inbox as an image-based doubt, with no AI draft attached.
- Approve button โ sends the AI's draft hint to the student as-is, banks it as a reusable answer, and logs a profile note.
- Edit button โ prompts the teacher for replacement text; their next message becomes the answer sent to the student.
- Reject button โ closes the doubt thread with nothing sent to the student.