Skip to main content

Overview

Sprout’s intelligence comes from seven specialized AI agents powered by Claude. Each agent has a specific role in designing, personalizing, and delivering your learning experience. All agents run through a shared agent loop that handles multi-turn tool calling, retry logic, and reasoning visibility.
Unlike traditional tutoring systems that follow pre-programmed rules, Sprout’s agents use Claude’s reasoning capabilities to make real-time decisions about your learning path.

Agent Loop Architecture

Every agent follows the same execution pattern:
Initial message → Claude → [text + tool_use blocks]

                    emit reasoning (visible to you)
                    execute tools
                    feed results back → Claude

                    repeat until complete

Key Features

Reasoning Visibility

The onThinking callback captures Claude’s reasoning text between tool calls, streamed as SSE events so you can watch agents think.

Retry with Backoff

429 rate limits are automatically retried with exponential backoff (2s, 4s, 8s) ensuring reliable execution.

Configurable Iterations

Default 15 iterations for complex tasks, tutor uses 5 for faster response times.

The Seven Agents

1. Topic Agent

Purpose: Design a complete learning path of 6-10 concepts for any topic.
ToolDescription
extract_all_concept_contextsBatch-extract relevant document sections for all concepts
save_conceptCreate a concept node in the database
save_concept_edgeCreate a dependency edge between concepts

2. Subconcept Bootstrap Agent

Purpose: Build the detailed learning structure for a single concept—diagnostic questions and a subconcept DAG.
ToolDescription
save_diagnostic_questionCreate MCQ or open-ended diagnostic questions
save_subconceptCreate a subconcept node
save_subconcept_edgeWire dependency edges between subconcepts
Subconcept bootstrap agents run in parallel with a concurrency limit of 3 to balance speed and API rate limits.

3. Concept Refinement Agent

Purpose: Personalize the subconcept graph after you answer diagnostic questions. This is Sprout’s star feature.
The Concept Refinement Agent follows an Observe-Reason-Act-Verify loop—the most sophisticated agent in the system.
ToolDescription
grade_student_answersGrade diagnostic answers via grading sub-agent
get_current_subconceptsView the existing subconcept graph structure
check_student_historyCross-concept performance (mastery, completed nodes, level)
add_subconceptAdd bridge/remedial subconcepts for knowledge gaps
remove_subconceptRemove mastered subconcepts (reconnects edges)
add_prerequisite_conceptInsert a concept BEFORE current in the topic path
add_followup_conceptInsert a concept AFTER current for reinforcement
validate_graphBFS check for orphans, broken edges, unreachable nodes

4. Tutor Agent

Purpose: Teach a subconcept interactively, chunk-by-chunk, with exercises and mastery tracking.
ToolDescription
check_student_progressLoad diagnostic results for the parent concept
check_prerequisite_masteryVerify prerequisite subconcepts are complete
generate_exampleCreate worked examples for illustration
create_exerciseGenerate practice problems (text, code, or drawing)
visualize_conceptCreate ASCII/text diagrams
record_exercise_resultPersist attempts and update mastery scores
The tutor uses only 5 agent loop iterations (vs. 15 default) for faster response times during interactive sessions.

5. Grade Answers Agent

Purpose: Grade diagnostic answers with scores, correctness flags, and detailed feedback. Flow:
  1. Receives question prompt, correct answer, and student answer
  2. Evaluates correctness (boolean)
  3. Assigns score (0.0 to 1.0)
  4. Writes constructive feedback
  5. Returns results to Concept Refinement Agent

6. Generate Diagnostic Agent

Purpose: Create 5-10 diagnostic questions for a concept when questions aren’t available. Output:
  • Mix of multiple-choice and open-ended questions
  • Varied difficulty levels
  • Questions that probe conceptual understanding (not just memorization)

7. Review Learning Path Agent

Purpose: Post-completion enrichment—decide if additional concepts or subconcepts should be added. Triggers:
  • When you complete a major concept
  • When overall topic progress exceeds 80%
  • When mastery scores suggest readiness for advanced material
Actions:
  • Insert enrichment nodes for deeper exploration
  • Add remediation if patterns suggest knowledge gaps
  • Suggest related topics for continued learning

Agent Orchestration

Two-Phase Topic Pipeline

POST /api/agents/topics/:topicNodeId/run

┌─ Phase 1: Topic Agent ─────────────────┐
│  Generates 6-10 concepts                │
│  Extracts document context              │
│  Saves nodes + edges via SSE            │
└─────────────────────────────────────────┘

┌─ Phase 2: Subconcept Bootstrap (×N) ───┐
│  Runs in parallel (max 3 concurrent)    │
│  Creates diagnostic questions           │
│  Creates subconcept DAG per concept     │
│  Streams SSE for each agent             │
└─────────────────────────────────────────┘

Concept Refinement Trigger

POST /api/agents/concepts/:conceptNodeId/run

Phase 1 (no answers): Return diagnostic questions as JSON
Phase 2 (answers exist): Stream concept refinement via SSE

Interactive Tutoring

POST /api/chat/sessions/:sessionId/tutor

Sends student message → AI tutor response with reasoning
Passes full context (userId, nodeIds, sessionId) for DB queries

Real-Time Streaming

All multi-step agent operations stream progress via Server-Sent Events:
Event TypeDataDescription
agent_start{ agent }Agent has started execution
agent_reasoning{ agent, text }Claude’s reasoning between tool calls
tool_call{ tool, input }Tool invocation with parameters
tool_result{ tool, summary }Tool result (truncated to 200 chars)
node_created{ node }New node persisted to database
edge_created{ edge }New edge persisted
node_removed{ nodeId }Node deleted by refinement agent
edge_removed{ sourceNodeId, targetNodeId }Edge deleted
agent_done{ agent, ... }Agent completed successfully
agent_error{ agent, message }Agent failed with error
The SSE writer in src/utils/sse.ts tracks all active agents and auto-closes the stream when all resolve.

Technical Details

Model

All agents use Claude 3.5 Sonnet (claude-3-5-sonnet-20241022) via the Anthropic SDK.

Tool Persistence Pattern

Agents never return data—they persist changes via tools:
// Tools save directly to the database
await db.insert(nodes).values({
  id: uuid(),
  title: input.title,
  variant: 'subconcept',
  // ...
});

// The agent sees the tool result, not the return value
return JSON.stringify({ success: true, nodeId });
This ensures all graph mutations are immediately reflected in the database and streamed to the frontend.

Reasoning Capture

The onThinking callback extracts text content between tool calls:
const textBlocks = response.content.filter(
  (block) => block.type === 'text'
);
if (textBlocks.length > 0) {
  onThinking?.(textBlocks.map(b => b.text).join('\n'));
}
This provides transparency into agent decision-making without requiring special prompting.

Complete Learning Flow

1. User creates topic

2. Topic Agent generates concepts

3. Subconcept Bootstrap Agents run in parallel

4. User answers diagnostic questions

5. Concept Refinement Agent personalizes graph

6. Tutor Agent teaches subconcepts

7. Review Agent suggests enrichment

Autonomous Design

Agents decide curriculum structure without human templates. Every learning path is custom-generated.

Self-Verification

The Concept Refinement Agent validates its own changes with BFS graph checks before committing.

Transparent Reasoning

Watch agents think in real-time via SSE reasoning events. Understand why decisions are made.

Tool-Based Actions

All graph mutations go through tools, ensuring database consistency and real-time UI updates.

Build docs developers (and LLMs) love