Skip to content

Hybrid educational agent for computational neuroscience combining structured tutor loops with knowledge graph navigation

Notifications You must be signed in to change notification settings

adrianmoses/edu-agent

Repository files navigation

Educational Agent for Computational Neuroscience

A hybrid TypeScript-based educational agent combining structured tutor loops with knowledge graph navigation, focused on teaching computational neuroscience concepts toward understanding whole brain emulation (WBE).

Architecture

This agent combines two pedagogical approaches:

  • OpenAI Approach: Structured generate → evaluate → update loop with tight feedback cycles
  • Anthropic Approach: Knowledge graph-based navigation with prerequisite awareness

Key Innovation: Graph-Enhanced Teaching Loop

The knowledge graph serves as an intelligent skill selector within the structured teaching loop:

1. GENERATE: SkillSelector queries KnowledgeGraph for eligible skills
            → DomainModule.generate() creates task using Claude
2. ATTEMPT: Learner provides response
3. EVALUATE: DomainModule.evaluate() assesses using Claude
4. UPDATE: LearnerStateManager updates mastery & error tracking
5. LOOP: Back to GENERATE with updated state

Features

  • 40 Computational Neuroscience Skills: From basic electrophysics to WBE computational requirements
  • Knowledge Graph: 20 concept nodes with prerequisite relationships
  • Adaptive Difficulty: Adjusts based on learner performance
  • Error Pattern Recognition: Identifies and remediates repeated mistakes
  • Progress Tracking: Monitors mastery levels and learning trajectory
  • Claude-Powered: Uses Claude 4.5 Sonnet for task generation and evaluation

Project Structure

edu-agent/
├── src/
│   ├── types/                    # TypeScript type definitions
│   │   ├── task.types.ts         # Task, TaskRequest, TaskMode
│   │   ├── eval.types.ts         # EvalResult, ErrorTag
│   │   ├── learner.types.ts      # LearnerState, MasteryEstimate
│   │   ├── graph.types.ts        # ConceptNode, Relationship
│   │   └── domain.types.ts       # DomainModule interface
│   ├── core/                     # Domain-agnostic teaching loop
│   │   ├── CoreLoop.ts           # Main orchestration
│   │   ├── LearnerStateManager.ts # State persistence
│   │   └── SkillSelector.ts      # Graph-based skill selection
│   ├── graph/                    # Knowledge graph
│   │   ├── KnowledgeGraph.ts     # Graph data structure
│   │   ├── GraphNavigator.ts     # Path finding, prereqs
│   │   └── data/
│   │       └── comp-neuro-graph.json  # 20 concept nodes
│   ├── domain/                   # Computational neuroscience
│   │   ├── CompNeuroDomain.ts    # Domain implementation
│   │   ├── TaskGenerator.ts      # Claude-based generation
│   │   ├── TaskEvaluator.ts      # Claude-based evaluation
│   │   ├── skills.ts             # 40 skill definitions
│   │   └── error-tags.ts         # Common error patterns
│   ├── llm/                      # LLM integration
│   │   ├── AnthropicClient.ts    # Claude SDK wrapper
│   │   └── prompts/              # Prompt templates
│   └── index.ts                  # Main entry point
└── data/
    └── learner-states/           # Persisted learner data

Setup

Prerequisites

  • Node.js 18+ and npm
  • Anthropic API key (Claude access)

Installation

  1. Clone the repository:
git clone <your-repo-url>
cd edu-agent
  1. Install dependencies:
npm install
  1. Create environment file:
cp .env.example .env
  1. Add your Anthropic API key to .env:
ANTHROPIC_API_KEY=your_api_key_here
  1. Build the project:
npm run build

Usage

Quick Start

Run the demo session:

npm start

This will:

  1. Initialize the educational agent
  2. Create or load a demo learner
  3. Generate a computational neuroscience task
  4. Simulate a learner attempt
  5. Evaluate the attempt and provide feedback
  6. Display progress metrics

Using as a Library

import {
  AnthropicClient,
  KnowledgeGraph,
  CompNeuroDomain,
  LearnerStateManager,
  SkillSelector,
  CoreLoop,
} from './src';

// Initialize components
const llmClient = new AnthropicClient(process.env.ANTHROPIC_API_KEY!);
const graph = await KnowledgeGraph.loadFromFile('./src/graph/data/comp-neuro-graph.json');
const domain = new CompNeuroDomain(llmClient, graph);
const stateManager = new LearnerStateManager('./data/learner-states');
const skillSelector = new SkillSelector(graph);
const coreLoop = new CoreLoop(domain, stateManager, skillSelector);

// Create a learner
await coreLoop.initializeLearner('student-1', 'Learn about WBE');

// Generate a task
const task = await coreLoop.generateTask('student-1', 'practice');

// Evaluate an attempt
const evaluation = await coreLoop.evaluateAttempt(
  'student-1',
  task,
  learnerAttempt
);

// Get progress
const progress = await coreLoop.calculateProgress('student-1');

API Reference

CoreLoop

Main orchestrator for the teaching loop.

Methods:

  • initializeLearner(id, goal) - Create new learner
  • generateTask(id, mode) - Generate next task ('practice' | 'test' | 'transfer')
  • evaluateAttempt(id, task, attempt) - Evaluate learner's response
  • teachingCycle(id, previousAttempt?, mode?) - Complete cycle (evaluate + generate)
  • getLearnerSummary(id) - Get learner statistics
  • calculateProgress(id) - Progress toward WBE understanding (0-1)
  • getSuggestedConcepts(id, count) - Get next recommended concepts

LearnerState

Tracks both short-term (recent tasks, errors) and long-term (goal, mastery) learning data.

Key Fields:

  • recentTasks: Task[] - Last 10 tasks
  • recentErrors: ErrorTag[] - Last 10 errors
  • masteryEstimates: Map<skillId, MasteryEstimate> - Per-skill mastery (0-1)
  • goal: string - Learning objective
  • currentFocus: string - Current concept node
  • demonstratedUnderstanding: Set<skillId> - Skills with high mastery

KnowledgeGraph

Concept graph with 20 nodes and prerequisite relationships.

Methods:

  • getNode(id) - Get concept node
  • getPrerequisites(nodeId) - Get prerequisite concepts
  • getDescendants(nodeId) - Get concepts this leads to
  • getSkillsForConcept(nodeId) - Get associated skills
  • findConceptsForSkill(skillId) - Find concept containing skill

Domain: Computational Neuroscience

40 Skills Organized by Difficulty

Foundational (1-2):

  • Ohm's law for membranes
  • Capacitance concept
  • Time constant calculation
  • Dimensional analysis
  • Steady state voltage

Membrane Dynamics (2-3):

  • Membrane differential equation
  • Time constant interpretation
  • Voltage/current clamp analysis
  • Exponential decay pattern
  • Subthreshold integration

Spike Generation (3-4):

  • LIF model implementation
  • Reset mechanism
  • Refractory period
  • Spike train analysis
  • F-I curve derivation

Stochastic Processes (3-4):

  • Poisson spike generation
  • Rate coding vs temporal coding
  • Coefficient of variation
  • Fano factor

Synaptic Dynamics (3-4):

  • Exponential/alpha synapse models
  • EPSP amplitude
  • Synaptic integration
  • STDP rule and window

Numerical Methods (4-5):

  • Euler method
  • Runge-Kutta implementation
  • Timestep selection
  • Numerical stability analysis
  • Computational cost analysis

WBE-Specific (4-5):

  • Neuron model complexity
  • Scaling analysis (1 → 1M neurons)
  • Parallelization potential
  • Fidelity tradeoffs
  • WBE computational requirements

Knowledge Graph

20 concept nodes organized from basic electrophysics to WBE requirements, with 35 prerequisite/related edges. Concepts are tagged by WBE relevance (core/supporting/advanced) and computational cost.

Design Decisions

1. Graph as Lookup Structure

The knowledge graph is queried by SkillSelector to filter eligible skills based on prerequisites. It's not a separate curriculum engine.

2. Skills vs Concepts

  • Skills (e.g., "time-constant-calculation") are task generation targets
  • Concepts (e.g., "membrane-time-constant") are graph nodes grouping related skills

3. Claude for Generate and Evaluate

V1 uses Claude 4.5 Sonnet for both operations. Separate prompt templates allow easy optimization later.

4. JSON Persistence

Learner state stored as JSON files (one per learner). Simple, debuggable, no database overhead.

5. Mastery via Exponential Moving Average

mastery = 0.7 * mastery + 0.3 * score - simple and responsive to recent performance.

6. Skill Selection Heuristics

if (repeatedErrors) → remediation tasks for that error
else if (recentSuccess && mode='transfer') → related skill at similar difficulty
else → next in prerequisite chain

V1 Success Criteria

After implementation, V1 succeeds if:

  1. Functional Loop: Can run 10+ generate→evaluate→update cycles
  2. Prerequisite Awareness: Doesn't assign advanced tasks before basics
  3. Remediation: Repeated errors trigger related skill tasks
  4. Transfer: Success on skill A leads to related skill B
  5. State Persistence: Learner state saves/loads correctly
  6. Pedagogical Quality: Tasks are clear, hints are useful

Future Extensions

V1.1: Enhanced Evaluation

  • Misconception detection (not just error tags)
  • Confidence-based hint generation
  • Careless error vs. misunderstanding distinction

V2: Spaced Repetition

  • Forgetting curve tracking
  • Scheduled review tasks
  • Long-term retention metrics

V3: Code Execution

  • Jupyter notebook integration
  • Neuron simulation tasks
  • Parameter sweep exercises

V4: Multimodal

  • Plot-based questions (raster plots, f-I curves)
  • Visual debugging tasks
  • Interactive simulations

Development

Build

npm run build

Run

npm start

Clean

npm run clean

License

MIT

Contributing

Contributions welcome! This is a V1 implementation with room for improvement in:

  • Domain-specific task quality
  • Prompt engineering
  • Additional subject domains
  • Advanced pedagogical features

Acknowledgments

  • Based on design principles from OpenAI and Anthropic educational agent approaches
  • Focused on computational neuroscience concepts from Dayan & Abbott, Gerstner et al.
  • Whole brain emulation concepts from Sandberg & Bostrom

About

Hybrid educational agent for computational neuroscience combining structured tutor loops with knowledge graph navigation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •