CoderAgent: Simulating Student Behavior for Personalized Programming Learning with Large Language Models

Yi Zhan, Qi Liu, Weibo Gao, Zheng Zhang, Tianfu Wang, Shuanghong Shen, Junyu Lu, Zhenya Huang

Introduction

Intelligent Tutoring Systems (ITS) for programming aim to provide personalized exercise recommendations and real-time hints to students. However, the development of these systems is frequently hindered by a significant data bottleneck. High-quality learner data—specifically the step-by-step trajectories of how students write and debug code—is difficult to collect, slow to accumulate, and heavily restricted by privacy regulations.

To address this, researchers have explored "student simulators." Yet, traditional simulators often treat programming as a binary outcome, predicting only whether a student's final submission will be correct. This approach ignores the iterative, localized nature of programming: the process of writing code, encountering compiler errors, and making specific line-level modifications. This paper introduces CoderAgent, an LLM-based framework designed to simulate the fine-grained, cognitive process of student coding and debugging.

The CoderAgent Framework

CoderAgent leverages Large Language Models (LLMs), such as GPT-4o, to mimic a student's coding workflow. Unlike standard LLM code generation, CoderAgent is constrained by a cognitive architecture that prevents it from simply providing the "expert" solution. The framework consists of four primary modules:

1. ACT-R Inspired Memory Module

Grounded in the ACT-R cognitive architecture, the agent’s memory is bifurcated into two components:

  • Long-term Memory: Stores the simulated student's programming knowledge, coding ability, unique stylistic preferences, and common misconceptions or error patterns.
  • Short-term Memory: Tracks the immediate context of the current task, including recent code snippets and feedback from the compiler.

2. Programming Tools

To mirror the human experience, the agent interfaces with external compilers. This allows the simulator to receive real-world syntax and runtime error feedback, which then informs the next iteration of the code.

3. Programming Tree of Thought (PTOT)

Standard LLMs often struggle with localized debugging, frequently rewriting entire scripts for minor errors. PTOT is a specialized reasoning framework that forces the agent to plan edits in four distinct steps:

  • Why: Identify the root cause of the error.
  • How: Determine the strategy to fix it.
  • Where: Pinpoint the specific lines requiring change.
  • What: Generate the exact code replacement.

4. Ability Reflection

To maintain the integrity of the student profile, this module performs a self-correction check. If the LLM proposes a solution that exceeds the simulated student's skill level (e.g., using an advanced lambda function for a beginner), the Reflection module rejects the edit and prompts a simpler, more realistic alternative.

Experimental Setup

The framework was evaluated using subsets of two real-world datasets:

  • CodeNet: A large-scale dataset from IBM containing Python submissions from online coding platforms (AIZU and AtCoder).
  • CSEDM: A college-level dataset featuring Java programming submissions from undergraduate students.

CoderAgent was tested across four predictive tasks: modification intention (Task 1), modification location (Task 2), the actual code of the next submission (Task 3), and the binary correctness of that submission (Task 4).

Key Insights and Results

Moving Beyond Binary Prediction

While traditional Knowledge Tracing (KT) models are limited to predicting correctness (Task 4), CoderAgent successfully handled all four tasks. This provides educators with a transparent window into how a student arrives at a solution, rather than just the final result.

Performance in Code Generation

In Task 3 (predicting the next code submission), CoderAgent significantly outperformed existing baselines. It achieved a CodeBLEU score of 0.769 on CSEDM and 0.590 on CodeNet, compared to the OKT baseline scores of 0.511 and 0.180, respectively. This suggests that the PTOT and memory modules effectively capture the incremental nature of student edits.

Handling Imbalanced Data

Predicting the correctness of the next submission in programming is notoriously difficult because students often make many incorrect attempts before a single successful one. While traditional KT models often struggle to perform better than random guessing (AUC ~0.50) on these imbalanced datasets, CoderAgent achieved AUCs between 0.549 and 0.552, demonstrating superior robustness.

Cold-Start Viability

Because CoderAgent relies on in-context learning and cognitive profiling rather than training on massive historical datasets, it is highly effective in "cold-start" scenarios where student data is initially unavailable.

Conclusion and Future Work

CoderAgent demonstrates that LLMs, when constrained by cognitive architectures and specialized reasoning frameworks like PTOT, can serve as realistic simulators for student behavior. By modeling the iterative debugging process, the framework provides a scalable way to generate synthetic data for training tutoring systems and identifying student misconceptions.

Future work will focus on reducing the financial costs associated with high-volume LLM API calls and integrating CoderAgent into live classroom environments for real-time exercise recommendations.

Summary updated

BibTeX
@inproceedings{zhan2025coderagent,
  author = {Yi Zhan and Qi Liu and Weibo Gao and Zheng Zhang and Tianfu Wang and Shuanghong Shen and Junyu Lu and Zhenya Huang},
  title = {{CoderAgent: Simulating Student Behavior for Personalized Programming Learning with Large Language Models}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.24963/ijcai.2025/34},
}
Figure