Skip to content
Studeia Docs

AI Tutor: multi-agent pipeline

Studeia multi-agent AI tutor pipeline: orchestrator, retrieval, pedagogical, evaluation, content, supervisor agents. Claude/GPT/Grok/Gemini fallback. Per-tenant RAG. Misconception detection.

2026-05-31 10 min
Resposta curta

Studeia AI tutor uses a multi-component pipeline: Orchestrator coordinates → StudentModelService loads student context → RetrievalAgent searches RAG → PedagogicalAgent selects strategy → the main LLM responds with automatic fallback → EvaluationAgent, ContentAgent, SupervisorAgent and summarization/memory tasks can run in background. Deterministic components have zero LLM cost; only LLM-backed components use TenantTaskModelConfig and metering.

Pipeline detailed

Pre-LLM (synchronous, zero LLM cost)

  1. StudentModelService.getSnapshot(userId, courseId) loads ConceptMastery (Beta distribution per concept), active/resolving misconceptions, EpisodicMemory, quizContext (avgScore, passRate, weakAreas), ChatSession history.
  2. RetrievalAgent.retrieve(query, studentModel) reformulates query, searches pgvector with tenant+course filters, boost by quizWeakAreas.
  3. PedagogicalAgent.select(studentModel, query) evaluates mastery + applies adjustments (chat-quiz divergence, age, learning style) → returns strategy.
  4. buildEnrichedPrompt assembles system prompt with strategy + RAG context + active misconceptions + recent quiz attempts.

Main LLM (streaming, SSE)

router.stream(taskType: "chat_tutor", messages, options) resolves provider via TenantTaskModelConfig. Fallback: Claude → OpenAI → xAI Grok → Google Gemini. Circuit breaker per provider (Redis state). Metering middleware: rate limit + credit check.

Post-LLM (background via after(), fire-and-forget)

  1. EvaluationAgent (Haiku, ~$0.001) classifies understanding, detects StudentMisconception, updates ConceptMastery (Bayesian).
  2. ContentAgent (Haiku, ~$0.001) pre-generates follow-up exercise (Redis 30min TTL).
  3. SessionSummarizer (every 10 turns, Haiku) summarizes long history.
  4. SupervisorAgent (Haiku, ~$0.001) classifies severity + category, applies strikes/quarantine.

Admin configuration

  • TenantTaskModelConfig chooses provider+model per task type
  • PedagogicalConfig configures thresholds per tenant (default 0.3, 0.5, 0.7, 0.9), domainOverrides, ageOverrides, learningStyleOverrides

Limitations

  • First-token latency: 800-1500ms (including pre-LLM pipeline)
  • Total turn latency: 2-8s for medium response (~300 words)
  • Context window: limited by provider (Claude Sonnet 4.6 = 200K, GPT-4o = 128K)
  • Talking avatar + voice (output): available as an opt-in per course — a real-time talking avatar with TTS voice via HeyGen LiveAvatar or D-ID (BYO provider key). See Avatar & TTS.
  • Voice input (STT): speaking to the tutor (student speech → speech-to-text → chat) is not implemented yet (roadmap).

See also

FAQ

How is the AI tutor pipeline composed?

The tutor uses a multi-component pipeline: deterministic TypeScript components handle orchestration, student context, RAG retrieval and pedagogical strategy; the main LLM generates the answer via the router; background LLM-backed tasks handle evaluation, content follow-ups, safety/supervision and session summarization when needed. Only LLM-backed components consume TenantTaskModelConfig and metering.

How much does a complete tutor turn cost?

Typically $0.005-$0.05 per complete turn. Breakdown: main LLM (Sonnet) $0.005-$0.04 + EvaluationAgent (Haiku) $0.001 + ContentAgent (Haiku) $0.001 + SupervisorAgent (Haiku) $0.001.

Can I disable the AI tutor for a specific course?

Yes. Course.aiTutorEnabled (boolean, default true). Institutional admin toggles in /institution/courses/[id]/settings.

Veja tambem

AI Tutor: multi-agent pipeline