NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Teach AI How to Code: Using Large Language Models as Teachable Agents for Programming Education

Hyoungwook Jin, Seonghee Lee, Hyungyu Shin, Juho Kim

TL;DR

This paper introduces AlgoBo, an LLM-based "teachable agent" designed to help humans learn programming by teaching it to the AI. By using a novel Reflect-Respond pipeline to artificially restrain the LLM's vast knowledge and Mode-shifting to prompt Socratic questioning, the system successfully nudges learners toward deeper "knowledge-building" rather than superficial fact-telling.

What Problem Does This Paper Address?

Learning by Teaching (LBT) is a powerful pedagogical method where a student learns a topic by explaining it to a peer. Teachable AI agents (virtual tutees) offer a scalable way to implement LBT without the social pressure of a human peer. However, the authors identify two major hurdles:

  1. Authoring Cost: Traditional teachable agents require thousands of lines of code to model specific subject-matter expertise.
  2. The "Expert" LLM Problem: While Large Language Models (LLMs) are easy to deploy, they are too smart. If a virtual tutee already knows the answer, the human "teacher" often defaults to "knowledge-telling" (reciting facts) rather than "knowledge-building" (explaining the why and how).

The researchers sought to create a system that could simulate a novice's misconceptions and lack of knowledge, forcing the human learner to engage more deeply with the material.

Methods

The authors developed TeachYou, a web-based learning environment featuring AlgoBo, a tutee powered by GPT-4. The system relies on three core technical components:

  • Reflect-Respond Pipeline: To prevent the LLM from using its pre-trained expertise, the authors decoupled the agent's knowledge from its reasoning.
  • Reflect: The agent extracts new information from the user's chat and updates a structured Knowledge State (a JSON object containing facts and code snippets).
  • Respond: The agent is strictly prompted to generate responses based only on its current Knowledge State. If the state is empty, the agent acts ignorant.
  • Mode-shifting: To prevent the conversation from becoming a one-way lecture, AlgoBo periodically shifts from a "help-receiver" to a "questioner." Every few turns, it asks a thought-provoking question (e.g., "Why is it faster than binary search?") to elicit elaboration from the user.
  • Teaching Helper: A real-time monitoring system that uses a message-type classifier to detect "antipatterns" in the user's teaching, such as "spoon-feeding" (giving answers without checking for understanding) or "commanding" (giving orders without explanation).
An overview of the core components of AlgoBo and TeachYou, showing the Reflect-Respond pipeline, Mode-shifting, and the Teaching Helper.

Datasets

The study utilized several data sources:

  • Formative Study Dialogues: 546 messages from 15 novices were used to develop a new taxonomy for LBT in programming.
  • Message Classifier Training: 438 messages were used to fine-tune a GPT-3 model to detect teaching patterns.
  • Technical Evaluation Benchmark: A custom set of 27 Multiple Choice Questions (MCQs) across three algorithm topics (Binary Search, Merge Sort, BFS), mapped to Bloom’s taxonomy (Understanding, Implementation, Analysis).

Key Insights and Ideas

  • Mechanical Ignorance is Essential: Simply telling an LLM to "act like a student" is insufficient; it will still leak expert knowledge. The Reflect-Respond architecture (Figure 5) provides a robust way to enforce a "gradual learning curve" for the AI.
  • The Power of the Socratic Tutee: The most significant learning gains in LBT come from the tutee's questions. By forcing the agent to ask "why," the system shifts the human from a passive role to an active one.
  • Antipattern Nudges: Humans often treat AI as a tool. The Teaching Helper acts as a metacognitive mirror, reminding users that their goal is to teach, not just to complete a task.
The Reflect-Respond pipeline in action, showing how the agent updates its knowledge state and composes a response based on retrieved knowledge.

Key Results

  • Technical Validation: The Reflect-Respond pipeline successfully reconfigured the agent's knowledge. In tests, an agent with an empty knowledge state correctly answered 0% of MCQs, while one provided with "Correct Tutoring" reached near-perfect scores.
  • Knowledge-Building Density: In a between-subjects study with 40 novices, the full TeachYou system (with Mode-shifting) significantly increased the density of knowledge-building messages compared to a baseline (8.4% vs 3.5%, $p=0.03$, Cohen’s $d=0.71$).
  • Perception of the Agent: Participants in the TeachYou condition were significantly more likely to perceive AlgoBo as a "student struggling to solve problems" ($p=0.01$) rather than a competent assistant.

Limitations and Future Work

  • Domain Specificity: The current prompts and classifiers are optimized for procedural programming knowledge. It is unclear if this approach generalizes to declarative subjects like history or biology.
  • Latency: The pipeline's complexity leads to response times of roughly 30 seconds, which can disrupt the conversational flow.
  • Longitudinal Effects: The study was a one-time session. Future work is needed to see if the "Teaching Helper" improves a user's metacognition over weeks or months.
  • Context-Aware Shifting: Currently, Mode-shifting happens on a fixed schedule (every 3 turns). The authors suggest that making this shift context-aware (e.g., waiting for a natural pause) would feel more intuitive.

Summary updated

BibTeX
@inproceedings{jin2024teach,
  author = {Hyoungwook Jin and Seonghee Lee and Hyungyu Shin and Juho Kim},
  title = {{Teach AI How to Code: Using Large Language Models as Teachable Agents for Programming Education}},
  booktitle = {CHI},
  year = {2024},
  doi = {10.1145/3613904.3642349},
}
Figure