Build with Mind Layer SDK
AI Tutors That Know Every Student
Your backend. Your frontend. Our Mind Layer handles persistent memory, goals, relationships, and adaptation. Here's exactly how to build it.
The End Result
This is what you can build.
A custom tutoring frontend backed by the Mind Layer. Student progress, knowledge gaps, adaptive difficulty — all powered by SDK calls to our platform. You own the UI. We handle the intelligence.
Student_456
CS Beginner · 23 sessions
Mastered
In Progress
Needs Review
Live Session · student-456
Can you explain recursion again? I keep getting confused about the base case.
I remember you had trouble with this last Thursday! Let me try a different approach. Think of recursion like Russian nesting dolls — each doll opens to reveal a smaller one inside, until you reach the tiniest doll that can't be opened. That's your base case.
Memory: recalled session from 5 days ago · Style: visual analogy (preferred)
Student Goals · student-456
Master recursion fundamentals
in progressLearn Big-O notation
pendingComplete sorting algorithms module
achievedStudent State · student-456
Relationship
Trust
0.82
Rapport
0.76
Familiarity
0.91
Current Mood
Constellation
Every panel above is powered by a single SDK call. Here's how ↓
Create Your AI Tutor
Generate the agent.
One API call creates an agent with a personality profile (Big Five traits), teaching style, interests, and initial goals. The agent is immediately ready to chat with students.
1import { Sonzai } from "sonzai";23const client = new Sonzai(); // uses SONZAI_API_KEY env45// Idempotent — same name always maps to the same agent6// Create the AI tutor with personality and goals7const tutor = await client.agents.create({8 name: "Professor Ada",9 bio: "A patient CS tutor who adapts to each student",10 gender: "female",11 personalityPrompt: "You are a patient computer science tutor...",12 primaryTraits: ["patient", "encouraging", "analytical"],13 big5: {14 openness: 90,15 conscientiousness: 85,16 extraversion: 60,17 agreeableness: 95,18 neuroticism: 15,19 },20 trueInterests: ["algorithms", "teaching", "visual learning"],21 speechPatterns: ["uses analogies", "asks guiding questions"],22 initialGoals: [{23 type: "skill_mastery",24 title: "Help students master CS fundamentals",25 description: "Guide each student through core CS concepts",26 priority: 2,27 }],28 toolCapabilities: { webSearch: true, rememberName: true },29});3031// Chat by name: agent: "Professor Ada" — no UUID neededWhat your frontend shows
Professor Ada
agent_id: ada-tutor-7x9k · Active
Chat with Persistent Memory
Every session builds on the last.
Send messages through the chat endpoint. The Mind Layer automatically persists memories, recalls relevant context, and adapts responses based on what it knows about each student. You can also search memories, get timelines, and list learned facts.
1// Student asks a question — Ada remembers their history2const response = await client.agents.chat({3 agent: "Professor Ada",4 messages: [{ role: "user", content: "Can you explain recursion again?" }],5 userId: "student-456",6 sessionId: "lesson-12",7});89console.log(response.content);10// "I remember you had trouble with this last Thursday!11// Let me try a different approach..."1213// Search what Ada remembers about this student14const memories = await client.agents.memory.search("Professor Ada", {15 query: "recursion understanding",16 userId: "student-456",17 limit: 10,18});1920// Get the full learning timeline21const timeline = await client.agents.memory.timeline("Professor Ada", {22 userId: "student-456",23});2425// List specific facts Ada has learned26const facts = await client.agents.memory.listFacts("Professor Ada", {27 userId: "student-456",28 category: "preference",29});What your frontend shows
Live Session · student-456
Can you explain recursion again? I keep getting confused about the base case.
I remember you had trouble with this last Thursday! Let me try a different approach. Think of recursion like Russian nesting dolls — each doll opens to reveal a smaller one inside, until you reach the tiniest doll that can't be opened. That's your base case.
Memory: recalled session from 5 days ago · Style: visual analogy (preferred)
Track Learning Goals
Create, read, update, complete.
The goal system tracks what each student is working toward. Create per-student goals with types like skill_mastery or learning_discovery, set priorities, and update status as students progress. Goals are also visible to the agent during conversation.
1// Create a learning goal for a specific student2const goal = await client.agents.createGoal("Professor Ada", {3 title: "Master recursion fundamentals",4 description: "Understand base cases, recursive calls, and stack behavior",5 type: "skill_mastery",6 priority: 2, // 0=low, 1=medium, 2=high7 userId: "student-456",8 relatedTraits: ["analytical", "persistent"],9});1011// Read all goals for this student12const goals = await client.agents.getGoals("Professor Ada", {13 userId: "student-456",14});1516// goals.goals → [{17// goalId: "g-abc123",18// title: "Master recursion fundamentals",19// status: "in_progress",20// priority: 2,21// type: "skill_mastery",22// }, ...]2324// Update goal when student makes progress25await client.agents.updateGoal("Professor Ada", goal.goalId, {26 userId: "student-456",27 status: "achieved",28});2930// Delete a goal that's no longer relevant31await client.agents.deleteGoal("Professor Ada", goal.goalId, {32 userId: "student-456",33});What your frontend shows
Student Goals · student-456
Master recursion fundamentals
in progressLearn Big-O notation
pendingComplete sorting algorithms module
achievedRead Student State
Relationships. Mood. Constellation.
The Mind Layer tracks the agent's evolving relationship with each student, its current mood, personality shifts over time, and a knowledge constellation mapping entities and connections. Read any of these to build insight dashboards for teachers or students.
1// Read the relationship between Ada and this student2const relationships = await client.agents.getRelationships("Professor Ada", {3 userId: "student-456",4});5// → { trust: 0.82, rapport: 0.76, familiarity: 0.91, ... }67// Read Ada's current mood toward this student8const mood = await client.agents.getMood("Professor Ada", {9 userId: "student-456",10});11// → { dominant: "engaged", valence: 0.7, arousal: 0.5, ... }1213// Read Ada's personality profile (evolves over time)14const personality = await client.agents.personality.get("Professor Ada", {15 historyLimit: 50,16});17// → { profile: { big5: { openness: 90, ... }, ... }, deltaHistory: [...] }1819// Get the knowledge constellation — entities and connections20const constellation = await client.agents.getConstellation("Professor Ada", {21 userId: "student-456",22});23// → { entities: [...], relationships: [...] }24// Maps topics, students, and concepts as a graph2526// Read Ada's diary entries (internal reflections)27const diary = await client.agents.getDiary("Professor Ada", {28 userId: "student-456",29});What your frontend shows
Student State · student-456
Relationship
Trust
0.82
Rapport
0.76
Familiarity
0.91
Current Mood
Constellation
Manage Learning Resources
Track what each student has.
The inventory system tracks per-student resources — assigned exercises, cheat sheets, tools, or any custom item type you define. Add items, query with filters, aggregate stats, or batch import a full curriculum. The agent is aware of the student's inventory during conversation.
1// Assign a learning resource to the student2const item = await client.agents.inventory.update("Professor Ada", "student-456", {3 action: "add",4 item_type: "exercise",5 description: "Big-O Practice Set",6 properties: { questions: 20, difficulty: "beginner", topic: "complexity" },7});89// Query what resources this student has10const inventory = await client.agents.inventory.query("Professor Ada", "student-456", {11 mode: "list",12});13// → { items: [{ factId: "f-xyz", itemLabel: "Big-O Practice Set", ... }], totalItems: 3 }1415// Query with aggregation — how many exercises completed?16const stats = await client.agents.inventory.query("Professor Ada", "student-456", {17 mode: "aggregate",18 item_type: "exercise",19 aggregations: "count",20 group_by: "difficulty",21});2223// Batch import a full curriculum24await client.agents.inventory.batchImport("Professor Ada", "student-456", {25 items: [26 { item_type: "resource", description: "Recursion Cheat Sheet", properties: { format: "pdf" } },27 { item_type: "tool", description: "Sorting Visualizer", properties: { interactive: true } },28 { item_type: "exercise", description: "Tree Traversal Problems", properties: { questions: 15 } },29 ],30});What your frontend shows
Student Inventory · student-456
Recursion Cheat Sheet
difficulty: beginner · format: pdf
Sorting Visualizer
interactive: true · topics: 5
Big-O Practice Set
questions: 20 · completed: 3
What You Get
Five endpoints. A complete tutoring platform.
Persistent Memory
Every conversation is remembered. The tutor recalls what each student struggled with, mastered, and prefers across sessions.
agents.chat() + agents.memory.*
Goal Tracking
Create structured learning objectives per student. The agent sees goals during conversation and can reference them.
agents.createGoal() / getGoals() / updateGoal()
Adaptive Personality
Big Five traits evolve based on interactions. The tutor naturally becomes more patient with struggling students.
agents.personality.get()
Relationship State
Track trust, rapport, and familiarity between tutor and student. Use these scores in your UI or for routing logic.
agents.getRelationships() / getMood()
Knowledge Constellation
A graph of entities and connections the tutor has learned about each student. Visualize topic maps and learning paths.
agents.getConstellation()
Resource Inventory
Track assigned materials, exercises, and tools per student with custom properties. Aggregate and filter with queries.
agents.inventory.update() / query()