AI Student Companion
A multi-tenant AI study companion. Every client gets their own isolated knowledge, and a student's session stays small and cheap however long it runs.
The idea
The problem
A study assistant needs to know the client's course material, remember the student, and use tools on their behalf. Done naively it sends huge prompts, costs a lot, can leak one client's data to another, and gives every user every tool.
The answer
Retrieval that is isolated per client, chunks that carry one idea each, a memory that keeps only what matters, and tools that are handed out per user instead of globally.
How a message is answered
A LangGraph agent sits in the middle. Everything around it is there to keep the context small, the data separate, and the tools scoped.
A student message arrives for a specific client and user. Audit logging starts here.
The tool injector pattern gives the agent only the tools this user is allowed to use.
pgvector search runs inside the client's own slice of the data, over propositional chunks.
A sliding window with importance scoring keeps what matters and drops the rest.
The model replies, with retry and fallback across Groq and Mistral. PII redaction runs on the way out.
The hard parts
Cost, isolation, and trust in one system.
Propositional chunking rewrites source text into self-contained statements. It compresses about 10:1 and cut retrieval tokens by 90%.
A sliding window with importance scoring cut a session from about 100K tokens to about 10K, so long conversations stay affordable.
Per-client isolation in a multi-tenant pgvector store. Retrieval cannot cross the line.
The tool injector pattern scopes each LLM tool to the user's permissions, plus PII redaction middleware and audit logging for the trail.
Retry and fallback across Groq and Mistral, deployed through Azure DevOps CI/CD and load-tested at 5–10 concurrent sessions.
Built with
| Agent | LangGraph, FastAPI |
|---|---|
| Data | PostgreSQL with pgvector, per-client isolation |
| Models | Groq and Mistral with retry and fallback |
| Safety | PII redaction middleware, audit logging, per-user tool scoping |
| Delivery | Docker, Azure DevOps CI/CD |