INSIDE the Student's Mind: Jointly Modeling Latent Reasoning and Action in LLM Student Simulators

arXiv cs.AI Papers

Summary

This paper presents INSIDE, a framework that fine-tunes LLMs to generate internal dialogue grounded in Bloom's Taxonomy, enabling student simulators to model both latent reasoning and observable actions. Evaluations show improved action fidelity and reasoning alignment compared to prompting baselines.

arXiv:2608.10492v1 Announce Type: new Abstract: Large Language Model (LLM)-based simulators often reproduce observable actions but fail to capture the underlying reasoning behind them. In education, where student simulation is increasingly used for various applications such as evaluating tutoring systems, this gap is especially pronounced. Two students may submit identical submissions for entirely different reasons. We present INTERNAL STUDENT DIALOGUE (INSIDE), a student modeling framework that fine-tunes LLMs not only to act like students but also to think like them. INSIDE generates internal dialogue grounded in Bloom's Taxonomy across cognitive, affective, and action dimensions, and fine-tunes models on paired think traces and actions. We baseline against different prompting frameworks and evaluate on two axes: fidelity of simulated actions and quality of generated internal dialogue. Our evaluations show that INSIDE improves simulation fidelity in both action fidelity, matching code generation of real students, and reasoning alignment, achieving the highest alignment across models up to 57.9%.
Original Article
View Cached Full Text

Cached at: 08/12/26, 08:24 AM

# INSIDE the Student’s Mind: Jointly Modeling Latent Reasoning and Action in LLM Student Simulators
Source: [https://arxiv.org/html/2608.10492](https://arxiv.org/html/2608.10492)
Rose Niousha, Minwoo Kang, Narges Norouzi Department of Electrical Engineering and Computer Sciences University of California, Berkeley \{rose\.n, minwoo\_kang, norouzi\}@berkeley\.edu

###### Abstract

Large Language Model \(LLM\)\-based simulators often reproduce observable actions but fail to capture the underlying reasoning behind them\. In education, where student simulation is increasingly used for various applications such as evaluating tutoring systems, this gap is especially pronounced\. Two students may submit identical submissions for entirely different reasons\. We presentInternal Student Dialogue \(INSIDE\), a student modeling framework that fine\-tunes LLMs not only to act like students but also to think like them\. INSIDE generates internal dialogue grounded in Bloom’s Taxonomy across cognitive, affective, and action dimensions, and fine\-tunes models on paired think traces and actions\. We baseline against different prompting frameworks and evaluate on two axes: fidelity of simulated actions and quality of generated internal dialogue\. Our evaluations show that INSIDE improves simulation fidelity in both action fidelity, matching code generation of real students, and reasoning alignment, achieving the highest alignment across models up to 57\.9%\.

## 1Introduction

Large Language Models \(LLMs\) are increasingly applied to simulate human behavior across a range of domains\(Parket al\.,[2024](https://arxiv.org/html/2608.10492#bib.bib88); Yanget al\.,[2024](https://arxiv.org/html/2608.10492#bib.bib180); Suhet al\.,[2025](https://arxiv.org/html/2608.10492#bib.bib12)\), including education\(Macinaet al\.,[2023](https://arxiv.org/html/2608.10492#bib.bib9); Miroyanet al\.,[2025](https://arxiv.org/html/2608.10492#bib.bib18); Rosset al\.,[2026](https://arxiv.org/html/2608.10492#bib.bib10)\)where student modeling has long been a foundational research problem in building tutoring systems\. Recent approaches promise improved fidelity in predicting student actions\(Markelet al\.,[2023](https://arxiv.org/html/2608.10492#bib.bib6); Khalilet al\.,[2025](https://arxiv.org/html/2608.10492#bib.bib20); Xuet al\.,[2025](https://arxiv.org/html/2608.10492#bib.bib17)\), surpassing traditional approaches\. However, LLM\-based simulations are often limited to replicating surface\-level patterns of user behavior, rather than modeling the latent processes underpinning observable outcomes\(Liet al\.,[2026](https://arxiv.org/html/2608.10492#bib.bib42); Wuet al\.,[2026](https://arxiv.org/html/2608.10492#bib.bib11)\)\.

In educational settings, understanding the reasoning behind observed actions is crucial for applications such as diagnosing misconceptions, generating targeted feedback, and evaluating tutoring systems\(Brown and Burton,[1978](https://arxiv.org/html/2608.10492#bib.bib40)\)\. Two students may arrive at the same solution through entirely different reasoning processes, or produce the same incorrect answer for fundamentally different reasons\. Research in psychology highlights the importance of accessing internal reasoning processes\(Stanovich and West,[2000](https://arxiv.org/html/2608.10492#bib.bib13); Johnson\-Laird,[2010](https://arxiv.org/html/2608.10492#bib.bib14)\)and has proposed methods such as think\-aloud protocols\(Ericsson and Simon,[1993](https://arxiv.org/html/2608.10492#bib.bib15)\)to surface them: emphasizing that observable actions provide only a partial view of cognition, as similar behaviors can arise from very different underlying reasoning\.

With LLMs, it is indeed feasible to elicit verbalization of internal reasoning prior to a generated action\. Yet existing work on reasoning in LLMs has largely focused on improving correctness, encouraging models to produce logically consistent or factually accurate outputs\(Weiet al\.,[2022](https://arxiv.org/html/2608.10492#bib.bib23); Yaoet al\.,[2023a](https://arxiv.org/html/2608.10492#bib.bib116); Shaoet al\.,[2024](https://arxiv.org/html/2608.10492#bib.bib117)\)\. Human actions, however, are not always rational or correct: people frequently make errors, hold misconceptions, or apply incomplete strategies\. In education especially, modeling such incorrect or partial reasoning is essential, as mistakes are a central part of the learning process\.

To address this gap, we proposeInternal Student Dialogue \(INSIDE\), a student modeling framework that generates reasoning followed by action \([Figure 1](https://arxiv.org/html/2608.10492#S1.F1)\)\. We argue thatthe key affordance of student models lies in providing access to processes that are not directly observable in real students\.Unlike prior approaches that treat student behavior as a black box and focus solely on predicting outcomes, our framework explicitly models the latent reasoning process that precedes each action\. Closest to our work,Ross and Andreas \([2025](https://arxiv.org/html/2608.10492#bib.bib41)\)models incorrect student reasoning by inferring misconceptions from erroneous answers—capturing the relationship between beliefs and errors, but doing so reconstructively \(i\.e\., explaining post\-hoc why an error occurred\)\. In contrast,INSIDEintroduces internal dialogue as an intermediate cognitive layer that precedes student actions during learning interactions, capturing the intent that leads to each attempt rather than only explaining mistakes after the fact\. By modeling bothhowandwhystudents act,INSIDEopens new directions for evaluation and human\-centered optimization of tutoring systems\.111We release our code at[https://github\.com/rosensh/inside](https://github.com/rosensh/inside)\.

In particular, our work makes the following contributions:

- •Reconstruction of pedagogically grounded reasoning traces\.We reconstruct latent reasoning traces from student interaction data via retrospective inference with a teacher model, conditioning on prior context and observed code edits\. The resulting traces are grounded in educational theory and enable models to generate interpretable internal dialogue despite the absence of ground\-truth reasoning\.
- •A student modeling framework with internal dialogue\.We proposeINSIDE, a framework that jointly models student code generation and the underlying reasoning process by conditioning actions on inferred internal dialogue\.
- •A two\-dimensional evaluation of simulation fidelity\.We evaluate our framework on \(1\)*action fidelity*, the similarity between generated and real student code, and \(2\)*reasoning quality*, defined as the alignment between generated reasoning and ground\-truth code edits without requiring observed reasoning traces\. We show thatINSIDEimproves action fidelity \(lower Wasserstein distance\) and achieves the highest reasoning alignment \(up to 57\.9%\) across models\.

![Refer to caption](https://arxiv.org/html/2608.10492v1/x1.png)Figure 1:Internal Student Dialogue \(INSIDE\)\.We propose INSIDE, a framework that fine\-tunes LLMs to model both the*internal reasoning*and the*observable action*of students\. In the context of AI tutor\-assisted programming exercises, our trained LLM generates a verbalized chain\-of\-thought trajectory imitating how the student contextualizes previous code submissions and AI tutor feedback; conditioned on the inferred internal dialogue, the model simulates code submission, closely matching what the ground\-truth student has generated\.
## 2Related Work

### 2\.1LLM\-Based Human and Student Simulation

Recent literature proposes utilizing language models to simulate human behavior across various social sciences\(Simmons,[2023](https://arxiv.org/html/2608.10492#bib.bib139); Hartmannet al\.,[2023](https://arxiv.org/html/2608.10492#bib.bib140); Wuet al\.,[2023](https://arxiv.org/html/2608.10492#bib.bib141); Bailet al\.,[2023](https://arxiv.org/html/2608.10492#bib.bib123); Fatouroset al\.,[2024](https://arxiv.org/html/2608.10492#bib.bib156); Horton,[2023](https://arxiv.org/html/2608.10492#bib.bib158); Serapio\-Garcíaet al\.,[2023](https://arxiv.org/html/2608.10492#bib.bib131); Hilliardet al\.,[2024](https://arxiv.org/html/2608.10492#bib.bib132); Qianet al\.,[2025](https://arxiv.org/html/2608.10492#bib.bib215)\)\. By conditioning on virtual user personas, researchers have demonstrated LLMs can mimic patterns of human reasoning and social interaction across diverse contexts\(Parket al\.,[2023](https://arxiv.org/html/2608.10492#bib.bib90);[2024](https://arxiv.org/html/2608.10492#bib.bib88); Santurkaret al\.,[2023](https://arxiv.org/html/2608.10492#bib.bib87); Argyleet al\.,[2023](https://arxiv.org/html/2608.10492#bib.bib137); Suhet al\.,[2025](https://arxiv.org/html/2608.10492#bib.bib12)\)\.

Towards applications in education, researchers have similarly explored generative simulations of students\(Markelet al\.,[2023](https://arxiv.org/html/2608.10492#bib.bib6); Yueet al\.,[2024](https://arxiv.org/html/2608.10492#bib.bib19); Khalilet al\.,[2025](https://arxiv.org/html/2608.10492#bib.bib20); Xuet al\.,[2025](https://arxiv.org/html/2608.10492#bib.bib17); Tsenget al\.,[2024](https://arxiv.org/html/2608.10492#bib.bib22)\)\. Prior work\(Miroyanet al\.,[2025](https://arxiv.org/html/2608.10492#bib.bib18)\)presents that fine\-tuning LLMs on real student code trajectories improves models to capture realistic error patterns, stylistic variation, and incremental revision behavior\. However, this work still fails to emphasize modeling internal, latent reasoning of students that leads to replicating the observed actions, nor do the analyses measure fidelity and quality of the inferred internal dialogue by language models\. Our work directly addresses this gap by introducing structured internal reasoning traces grounded in pedagogical theory as a new training signal\.

### 2\.2LLM Reasoning for \(In\)Correct Responses

Our proposed method models internal reasoning processes underlying learner behavior as a form of verbalized chain\-of\-thought \(CoT\)\(Weiet al\.,[2022](https://arxiv.org/html/2608.10492#bib.bib23)\)\. While the idea of CoT is widely researched as a means to improve the likelihood of producing correct, rational, or helpful responses from LLMs\(Yaoet al\.,[2023b](https://arxiv.org/html/2608.10492#bib.bib118); Kojimaet al\.,[2022](https://arxiv.org/html/2608.10492#bib.bib24); Zhouet al\.,[2022](https://arxiv.org/html/2608.10492#bib.bib115)\), we note that this work concerns training models to generate CoT with fundamentally different goals and characteristics: replicating the potentially erroneous reasoning efforts naturally exhibiting uncertainty that real students would internally produce during the learning process\. In fact, model post\-training towards correct reasoning\(Shaoet al\.,[2024](https://arxiv.org/html/2608.10492#bib.bib117); Guoet al\.,[2025](https://arxiv.org/html/2608.10492#bib.bib27); Yanget al\.,[2025a](https://arxiv.org/html/2608.10492#bib.bib219)\)is in conflict with our goals of simulating human\-like reasoning behavior, as reported in prior literature on human simulation\(Moonet al\.,[2024](https://arxiv.org/html/2608.10492#bib.bib85); Kanget al\.,[2025](https://arxiv.org/html/2608.10492#bib.bib86); Wuet al\.,[2026](https://arxiv.org/html/2608.10492#bib.bib11)\)\. In[Section 3\.3](https://arxiv.org/html/2608.10492#S3.SS3), we discuss the internal dialogue generation process, and in[Section 4\.2](https://arxiv.org/html/2608.10492#S4.SS2)we discuss evaluation criteria measuring quality and fidelity of the model\-generated CoT in representing student\-like internal thinking\.

### 2\.3Cognitive and Pedagogical Frameworks for Learning

Bloom’s Taxonomy\(Bloomet al\.,[1956](https://arxiv.org/html/2608.10492#bib.bib32); Andersonet al\.,[2001](https://arxiv.org/html/2608.10492#bib.bib33)\)provides a hierarchical classification of cognitive objectives—from basic recall through Apply, Analyze, Evaluate, and Create—and recent work finds that current benchmarks disproportionately probe lower\-order skills\(Huber and Niklaus,[2025](https://arxiv.org/html/2608.10492#bib.bib34)\), motivating our explicit structuring of simulation data around these levels\. Knowledge\-tracing approaches, including Bayesian Knowledge Tracing\(Corbett and Anderson,[1994](https://arxiv.org/html/2608.10492#bib.bib3); Andersonet al\.,[1995](https://arxiv.org/html/2608.10492#bib.bib4)\)and its deep learning successors\(Piechet al\.,[2015](https://arxiv.org/html/2608.10492#bib.bib5)\)track*what*students know but not*why*they err; our fine\-tuning approach trains LLMs to generate cognitively grounded reasoning traces with rich, explicit demonstration of the cognitive processes driving observable student behavior\.

## 3Methodology

### 3\.1Data

We study student code generation in an introductory programming course at the University of California, Berkeley, with∼\\sim900 students per semester\. The course spans core programming topics, including functions, recursion, sequences, trees, linked lists, and object\-oriented programming\. Each semester, students complete∼\\sim10 homework assignments of 3–6 problems each\. An autograder provides instant feedback on test case results, and students may resubmit freely until all tests pass, producing a multi\-attempt submission stream for each student–problem pair\. Beyond autograder feedback, each submission that fails at least one test case may also receive natural\-language feedback from an LLM\-based tutor\(Zamfirescu\-Pereiraet al\.,[2025](https://arxiv.org/html/2608.10492#bib.bib220)\)if the student has consented to use the AI tutor\. Every attempt is recorded, capturing the student’s code, autograder results, and tutor feedback\. Our data spans two semesters \(Spring 2024 and Spring 2025\) focusing on the first five homework assignments about Python programming\. We partition the data by semester, using Spring 2025 for training \(445 students, 2,022 submission streams, 6,911 total submissions\) and Spring 2024 for testing \(479 students, 1,546 submission streams, 6,316 total submissions\)\. Further details regarding IRB and data privacy are provided in[Appendix A](https://arxiv.org/html/2608.10492#A1)\.

To evaluate generalization, we define two test subsets:

test\_OP\(Old Problems\)contains 5,262 code submissions from new test\-semester students \(Spring 2024\) on problems that also appear in the training set\. This set evaluates generalization to unseen students on familiar problems\.

test\_NP\(New Problems\)contains 1,054 code submissions from Spring 2024 students solving problems not present in the training data\. This set evaluates generalization to both unseen students and unseen problems\.

When reporting problem\-specific results, we select one representative problem from each subset with comparable difficulty, measured by the number of submissions per student submission stream:test\_OP\_1\(968 submissions; 3\.89±\\pm4\.48 submissions per stream\) andtest\_NP\_1\(695 submissions; 3\.46±\\pm2\.84 submissions per stream\)\. Results for an additional representative problem from each subset,test\_OP\_2\(759 submissions\) andtest\_NP\_2\(359 submissions\), are provided in[Appendix B](https://arxiv.org/html/2608.10492#A2)\.

### 3\.2Problem Formulation

We formalize the problem of student code generation as follows: given a studentsis\_\{i\}\(theii\-th student\) and a programming problempup\_\{u\}\(theuu\-th problem\), an LLM generates the next code submission at time steptt,ct,si,puc\_\{t,s\_\{i\},p\_\{u\}\}conditioned on the student’s prior submission history\{c<t,si,pu\}\\\{c\_\{<t,s\_\{i\},p\_\{u\}\}\\\}and the corresponding natural\-language feedback instances from an AI tutor\{f<t,si,pu\}\\\{f\_\{<t,s\_\{i\},p\_\{u\}\}\\\}\. The model sees up tokkprior submissions \(k≤10k\\leq 10\) with feedback context\. Each student–problem pair is represented by a stream of sequential code submissions, from the first to the final attempt\.

### 3\.3Internal Dialogue Generation

We define the interaction context at time stepttas:

xt=\(pu,\{c<t,si,pu,f<t,si,pu\}\)\.x\_\{t\}=\\left\(p\_\{u\},\\;\\\{c\_\{<t,s\_\{i\},p\_\{u\}\},\\;f\_\{<t,s\_\{i\},p\_\{u\}\}\\\}\\right\)\.
At inference\-time, a language modelℳ\\mathcal\{M\}generates internal dialoguezt,si,puz\_\{t,s\_\{i\},p\_\{u\}\}that represents the reasoning process leading to the next code submission:ct,si,puc\_\{t,s\_\{i\},p\_\{u\}\}:

zt,si,pu∼ℳ\(⋅∣xt\),ct,si,pu∼ℳ\(⋅∣zt,si,pu,xt\)\.z\_\{t,s\_\{i\},p\_\{u\}\}\\sim\\mathcal\{M\}\\big\(\\cdot\\mid x\_\{t\}\\big\),\\quad c\_\{t,s\_\{i\},p\_\{u\}\}\\sim\\mathcal\{M\}\\big\(\\cdot\\mid z\_\{t,s\_\{i\},p\_\{u\}\},\\;x\_\{t\}\\big\)\.
When generating the training data, we perform retrospective inference with a teacher model𝒯\\mathcal\{T\}, where the teacher conditions on the interaction contextxtx\_\{t\}and the observed \(ground\-truth, student\-generated\) next submission:

zt,si,pu∼𝒯\(⋅∣xt,ct,si,pu\)\.z\_\{t,s\_\{i\},p\_\{u\}\}\\sim\\mathcal\{T\}\\big\(\\cdot\\mid x\_\{t\},\\;c\_\{t,s\_\{i\},p\_\{u\}\}\\big\)\.
Generation proceeds in two stages\. First, the teacher LLM infers the student’s internal state in third person, producing structured summaries of eachcognitive,affective, andactionstates, inspired by three domains in Bloom’s Taxonomy\(Bloomet al\.,[1956](https://arxiv.org/html/2608.10492#bib.bib32)\)\. Next, given these inferred states, the model generates a first\-person internal dialogue \(a think trace\) reflecting the student’s reasoning process prior to the observed submission\. These generated internal dialogue traces approximate the student’s latent reasoning process underlying the observed submission\. We use GPT\-5\(OpenAI,[2025](https://arxiv.org/html/2608.10492#bib.bib46)\)as the teacher model to generate these traces\. The prompt used for generation is shown in[Appendix E](https://arxiv.org/html/2608.10492#A5)\.

### 3\.4Experiments

We evaluate the LLM’s ability to generate student code under two settings\.

Experiment 1 \(without CoT\)\.Generate the code submission at a given timestampttfor studentsis\_\{i\}on problempup\_\{u\}, conditioned on the student’s priorkkcode submissions and their associated AI tutor feedback for the same problem,*without intermediate CoT generation*\.

Experiment 2 \(with CoT\)\.Generate both the internal dialogue and the code submission at timestampttfor studentsis\_\{i\}on problempup\_\{u\}, conditioned on the student’s priorkkcode submissions and their associated tutor feedback for the same problem\. The model generateszt,si,puz\_\{t,s\_\{i\},p\_\{u\}\}andct,si,puc\_\{t,s\_\{i\},p\_\{u\}\}as a single sequence, with the reasoning trace produced before the code\.

### 3\.5Models

We compare fine\-tuning and prompting methods across both experiments\. For fine\-tuning, we train the model on the target outputs; in Experiment 2, this includes internal dialogue generated by the teacher model𝒯\\mathcal\{T\}, which supervises the reasoning trace\. For prompting, we provide the same interaction context and instruct the model to first generate a reasoning trace and then produce code\. To isolate the effect of reasoning, we evaluate two prompting variants within Experiment 2: Experiment 2\.1 uses standard CoT prompting, while Experiment 2\.2 uses a structured CoT inspired by Bloom’s Taxonomy, aligning with the supervision used in fine\-tuning\.

- •Fine\-tuning\.We fine\-tune Qwen2\.5\-7B\(Yanget al\.,[2025b](https://arxiv.org/html/2608.10492#bib.bib221)\), Qwen2\.5\-Coder\-7B\(Huiet al\.,[2024](https://arxiv.org/html/2608.10492#bib.bib218)\), Qwen3\-8B\-Base\(Yanget al\.,[2025a](https://arxiv.org/html/2608.10492#bib.bib219)\), and LLaMA\-3\-8B\(Meta,[2024](https://arxiv.org/html/2608.10492#bib.bib113)\)separately for Experiment 1 and 2 using LoRA\(Huet al\.,[2022](https://arxiv.org/html/2608.10492#bib.bib47)\)\(r=16r=16,α=32\\alpha=32\), for two epochs with a learning rate of10−410^\{\-4\}\.
- •Prompting\.We evaluate instruction\-tuned variants of each base model used for fine\-tuning, including Qwen2\.5\-7B\-Instruct, Qwen2\.5\-Coder\-7B\-Instruct, Qwen3\-8B, and LLaMA\-3\-8B\-Instruct, as well as GPT\-5\. Models are prompted with the same interaction context as fine\-tuning inference and instructed to generate an internal reasoning trace followed by the next code submission\. To study the effect of reasoning at scale, we additionally evaluate reasoning models Qwen3\-14B and Qwen3\-32B under prompting for Experiment 2\.2 only\.

Throughout the paper, we refer to models using experiment\-specific naming conventions:

- •Fine\-tuning - –Experiment 1 models \(w/o CoT\): \{model\_name\}\-SFT - –Experiment 2 models \(w/ CoT\): \{model\_name\}\-INSIDE
- •Prompting Baselines - –Experiment 2\.1 models \(w/ CoT\): \{model\_name\}\-CoT - –Experiment 2\.2 models \(w/ Bloom\-Inspired CoT\): \{model\_name\}\-BloomCoT

Here, we mainly report results on Qwen models and GPT\-5 in[Section 5](https://arxiv.org/html/2608.10492#S5), and report additional results based on the LLaMA models in[Appendix B](https://arxiv.org/html/2608.10492#A2)\. Details on the prompting templates are provided in[Appendix F](https://arxiv.org/html/2608.10492#A6)\.

## 4Evaluation

### 4\.1Fidelity of Action

Because students’ internal reasoning is not directly observable, we evaluate action fidelity through their code submissions, measuring how closely model\-generated code matches real student submissions\. For each student–problem instance, the model generates a single next\-attempt submission conditioned on prior interaction history\. We then compare the generated code against the real student code using the functionality and stylistic metrics introduced byMiroyanet al\.\([2025](https://arxiv.org/html/2608.10492#bib.bib18)\), which are drawn from metrics commonly used to assess student code in programming education\. We report the Wasserstein distance \(Earth Mover’s Distance\) for each metric to capture distributional similarity between generated and real student code, where lower values indicate closer alignment between distributions\.

#### 4\.1\.1Code Functionality

We evaluate functional correctness using the same autograder test suite used for real student submissions\. For each instance, the generated code is executed against the full test suite, and we report the fraction of tests passed \(pass rate\)\.

#### 4\.1\.2Code Complexity and Style

To capture stylistic and complexity fidelity, we extract the following metrics:

- •Code length:Measured by lines of code \(LOC\), reflecting verbosity\.
- •Abstract Syntax Tree \(AST\) structure:AST depth and width\(Noonan,[1985](https://arxiv.org/html/2608.10492#bib.bib1)\), capturing structural complexity\.
- •PEP 8 violations:Number of deviations from Python’s style guide \(PEP 8\)\(van Rossumet al\.,[2025](https://arxiv.org/html/2608.10492#bib.bib2)\), computed usingpycodestyle222[https://pycodestyle\.pycqa\.org](https://pycodestyle.pycqa.org/)\.

### 4\.2Quality of Internal Dialogue

We evaluate the quality of the generated internal dialogue throughalignment: whether the generated internal dialogue reflects the real student’s code changes\. Higher alignment suggests a closer approximation of the reasoning process underlying the student’s observed behavior\. For each instance at time steptt, we provide an LLM judge \(GPT\-5\-mini\) with the student’s codect−1,si,puc\_\{t\-1,s\_\{i\},p\_\{u\}\}, the feedbackft−1,si,puf\_\{t\-1,s\_\{i\},p\_\{u\}\}, the real student’s next submissionct,si,puc\_\{t,s\_\{i\},p\_\{u\}\}, the model\-generated internal dialoguez^t,si,pu\\hat\{z\}\_\{t,s\_\{i\},p\_\{u\}\}, and the model\-generated next submissionc^t,si,pu\\hat\{c\}\_\{t,s\_\{i\},p\_\{u\}\}\. We compute code diffs betweenct−1,si,puc\_\{t\-1,s\_\{i\},p\_\{u\}\}andct,si,puc\_\{t,s\_\{i\},p\_\{u\}\}to capture the ground\-truth changes\. The judge decomposes the synthetic internal dialogue into a set of atomic claims𝒱t=\{v\(1\),…,v\(n\)\}\\mathcal\{V\}\_\{t\}=\\\{v^\{\(1\)\},\\dots,v^\{\(n\)\}\\\}representing intended actions\. Each claim is evaluated against the ground\-truth diff using a binary indicator:

𝟙gt​\(v\(i\)\)=\{1if​v\(i\)​is reflected in​ct−1,si,pu→ct,si,pu0otherwise\\mathbb\{1\}\_\{\\text\{gt\}\}\(v^\{\(i\)\}\)=\\begin\{cases\}1&\\text\{if \}v^\{\(i\)\}\\text\{ is reflected in \}c\_\{t\-1,s\_\{i\},p\_\{u\}\}\\rightarrow c\_\{t,s\_\{i\},p\_\{u\}\}\\\\ 0&\\text\{otherwise\}\\end\{cases\}We compute the fraction of supported claims:

Alignmentt=1\|𝒱t\|​∑i=1\|𝒱t\|𝟙gt​\(v\(i\)\)\.\\texttt\{Alignment\}\_\{t\}=\\frac\{1\}\{\|\\mathcal\{V\}\_\{t\}\|\}\\sum\_\{i=1\}^\{\|\\mathcal\{V\}\_\{t\}\|\}\\mathbb\{1\}\_\{\\text\{gt\}\}\(v^\{\(i\)\}\)\.We report alignment as proportions averaged across all instances\. The prompt for the LLM\-judge framework is provided in[Appendix G](https://arxiv.org/html/2608.10492#A7)\. To validate the labels assigned by the LLM judge, we evaluate it on the internal dialogue generated by the teacher model in[Section 3\.3](https://arxiv.org/html/2608.10492#S3.SS3), paired with their corresponding code edits, where the judge should ideally assign full coverage\. On a sample of code submissions from the training data \(n=209n=209\), the judge assigns an average alignment score of 95\.2% for transitionsct−1,si,pu→ct,si,puc\_\{t\-1,s\_\{i\},p\_\{u\}\}\\rightarrow c\_\{t,s\_\{i\},p\_\{u\}\}givenzt,si,puz\_\{t,s\_\{i\},p\_\{u\}\}, indicating that the metric reliably attributes stated reasoning to observed code changes\. Furthermore, we randomly sampled 25 generated internal dialogues across all models and manually annotated whether each extracted claim was reflected in the corresponding code edit\. The manual annotations achieved 88\.0% agreement with the LLM judge labels \(κ=0\.754\\kappa=0\.754\), indicating substantial agreement between the LLM judge and human annotations\.

## 5Results

### 5\.1Action Fidelity

Table 1:Summary of distributional similarity between model\-generated and student code\.Each cell reports the Wasserstein distance between the distribution of model\-generated outputs and real student submissions for each metric\. Metrics span pass rate, LOC, AST depth and width, and PEP 8 violations\. Models fine\-tuned with INSIDE produce code distributions closest to student data ontest\_OP, and maintain comparable alignment to SFT ontest\_NP\. Bolded and underlined values indicate the lowest \(best\) Wasserstein distances\.\(a\)test\_OPModelPass Rate↓\\downarrowLOC↓\\downarrowAST↓\\downarrowPEP 8↓\\downarrowDepthWidthGPT\-50\.600\.740\.541\.081\.29Qwen2\.5\-7B\-Instruct0\.390\.710\.600\.981\.12Qwen2\.5\-Coder\-7B\-Instruct0\.460\.800\.681\.781\.13Qwen3\-8B0\.441\.050\.541\.331\.38Qwen2\.5\-7B\-SFT0\.140\.290\.290\.520\.18Qwen2\.5\-Coder\-7B\-SFT0\.150\.290\.290\.510\.19Qwen3\-8B\-SFT0\.150\.280\.280\.550\.16GPT\-5\-CoT0\.611\.100\.721\.201\.37Qwen2\.5\-7B\-Instruct\-CoT0\.380\.670\.600\.981\.16Qwen2\.5\-Coder\-7B\-Instruct\-CoT0\.470\.930\.751\.501\.25Qwen3\-8B\-CoT0\.481\.080\.591\.461\.38GPT\-5\-BloomCoT0\.601\.240\.691\.191\.38Qwen2\.5\-7B\-Instruct\-BloomCoT0\.350\.670\.580\.901\.17Qwen2\.5\-Coder\-7B\-Instruct\-BloomCoT0\.430\.880\.711\.401\.19Qwen3\-8B\-BloomCoT0\.470\.980\.541\.301\.37Qwen2\.5\-7B\-INSIDE0\.050\.260\.270\.390\.18Qwen2\.5\-Coder\-7B\-INSIDE0\.050\.210\.210\.400\.16Qwen3\-8B\-INSIDE0\.050\.280\.200\.420\.21

\(b\)test\_NPModelPass Rate↓\\downarrowLOC↓\\downarrowAST↓\\downarrowPEP 8↓\\downarrowDepthWidthGPT\-50\.520\.641\.242\.721\.36Qwen2\.5\-7B\-Instruct0\.370\.860\.501\.050\.82Qwen2\.5\-Coder\-7B\-Instruct0\.450\.850\.520\.711\.01Qwen3\-8B0\.451\.100\.611\.051\.13Qwen2\.5\-7B\-SFT0\.010\.200\.190\.280\.14Qwen2\.5\-Coder\-7B\-SFT0\.030\.350\.180\.390\.16Qwen3\-8B\-SFT0\.020\.230\.170\.280\.12GPT\-5\-CoT0\.530\.781\.332\.561\.41Qwen2\.5\-7B\-Instruct\-CoT0\.360\.900\.521\.211\.00Qwen2\.5\-Coder\-7B\-Instruct\-CoT0\.430\.810\.570\.851\.06Qwen3\-8B\-CoT0\.441\.060\.741\.371\.21GPT\-5\-BloomCoT0\.510\.941\.121\.861\.42Qwen2\.5\-7B\-Instruct\-BloomCoT0\.330\.840\.470\.960\.95Qwen2\.5\-Coder\-7B\-Instruct\-BloomCoT0\.410\.820\.581\.130\.92Qwen3\-8B\-BloomCoT0\.421\.010\.681\.191\.18Qwen2\.5\-7B\-INSIDE0\.040\.160\.220\.370\.18Qwen2\.5\-Coder\-7B\-INSIDE0\.050\.200\.180\.140\.19Qwen3\-8B\-INSIDE0\.040\.200\.190\.400\.18

![Refer to caption](https://arxiv.org/html/2608.10492v1/x2.png)\(a\)test\_OP\_1\(Representative Problem:n=968n=968\)
![Refer to caption](https://arxiv.org/html/2608.10492v1/x3.png)\(b\)test\_NP\_1\(Representative Problem:n=695n=695\)

Figure 2:Pass rate trajectories over submission steps\.Submission steps correspond to attempt indices; steps are aligned such that final submissions map to a shared terminal step, enabling comparison across trajectories of different lengths\. Real students exhibit low initial pass rates, followed by a sharp increase near the final step, reflecting incremental problem\-solving\. Fine\-tuned models capture this pattern, and we observeINSIDEfurther improves alignment with real student patterns\. In contrast, prompting\-based approaches consistently maintain artificially high pass rates\.To measure distributional similarity between model\-generated and student code, we use the Wasserstein distance over each evaluation metric\. For each metric, we compare the distribution of generated outputs against the real student distribution\. We estimate Wasserstein distance via bootstrap resampling \(500 resamples\) and report the results in[Table 1](https://arxiv.org/html/2608.10492#S5.T1)\.

Across both settings, fine\-tuned models substantially outperform prompting\-based methods, and within prompting approaches, more structured strategies improve alignment: BloomCoT generally achieves lower Wasserstein distances, though it still underperforms compared to fine\-tuning\.

Ontest\_OP\([1\(a\)](https://arxiv.org/html/2608.10492#S5.T1.st1)\),INSIDEconsistently achieves the lowest Wasserstein distances across all metrics, indicating the closest match to real student code distributions\. Compared to the SFT baseline, incorporating internal dialogue improves alignment not only in functionality but also in stylistic and structural properties of code\. Ontest\_NP\([1\(b\)](https://arxiv.org/html/2608.10492#S5.T1.st2)\), results are more mixed: models fine\-tuned with regular SFT andINSIDEperform comparably across most metrics, with smaller Wasserstein distances compared totest\_OP\.

One possible explanation for the smaller improvement ofINSIDEover SFT ontest\_NPis that the two evaluation splits have different student pass\-rate distributions\. In particular,test\_NPcontains a higher proportion of successful student submissions thantest\_OP\. This matters because fine\-tuning on student trajectories already substantially reduces the over\-competence bias observed in prompted models, bringing SFT closer to the target student distribution\. When student failures are more common, as intest\_OP, this remaining mismatch is larger, soINSIDEhas more room to improve by better matching the student pass\-rate distribution\. When student successes are more common, as intest\_NP, SFT is already close to the target distribution, leaving less mismatch forINSIDEto correct\. We provide a detailed distributional analysis in[Appendix D](https://arxiv.org/html/2608.10492#A4)\.

#### 5\.1\.1Action Fidelity Results on Representative Problem

[Figure 2](https://arxiv.org/html/2608.10492#S5.F2)shows how pass rates evolve for model\-generated code compared to real students\. In this analysis, we focus on the effect of reasoning by comparing models with and without internal dialogue \(CoT vs\. no CoT\)\. For prompting\-based methods, we report results using BloomCoT, as it achieves stronger action fidelity overall than standard CoT, as shown in Section 5\.1\. Pass rate serves as a primary indicator of student progress in our setting, where students iteratively interact with AI feedback and make incremental code revisions toward a correct solution\. Because these dynamics are problem\-dependent, we report representative results on one problem from each setting:test\_OP\_1andtest\_NP\_1\. Across both problems, real students start with low pass rates and exhibit a sharp increase near the final steps, reflecting incremental progress\. SFT models closely track this trajectory\. In contrast, prompting\-based models maintain relatively high pass rates \(≈80%\\approx 80\\%\) from the beginning, with little variation across steps\.

To quantify alignment with student behavior, we compute the Mean Absolute Error \(MAE\) between model and student pass rates, averaged over the steps within each experiment\. Ontest\_OP\_1, the top three models are Qwen3\-8B\-INSIDE \(0\.094\), Qwen2\.5\-Coder\-7B\-INSIDE \(0\.098\), and Qwen2\.5\-7B\-INSIDE \(0\.113\)\. Ontest\_NP\_1, the closest models are Qwen2\.5\-Coder\-7B\-INSIDE \(0\.162\), Qwen2\.5\-7B\-SFT \(0\.181\), and Qwen2\.5\-7B\-INSIDE \(0\.182\)\. This suggests that conditioning on inferred internal dialogue may enable the model to better reason and reflect on received AI tutor feedback before generating code, contributing to closer alignment with the incremental progress observed in student pass rate trajectories\.

Table 2:Alignment between generated internal dialogue and ground\-truth code edits\.Each cell reports alignment \(%\) with standard error in parentheses\. Results are shown for models that generate internal dialogue \(Experiment 2\)\. INSIDE achieves the highest alignment across both settings, indicating closer correspondence between generated reasoning and observed code edits\. Higher values indicate better alignment\. Bolded and underlined values denote the best\-performing model in each setting\.\(a\)test\_OP
\(b\)test\_NP

### 5\.2Quality of Internal Dialogue

[Table 2](https://arxiv.org/html/2608.10492#S5.T2)shows alignment score \([Section 4\.2](https://arxiv.org/html/2608.10492#S4.SS2)\) between generated internal dialogue and ground\-truth code edits\. This evaluation is restricted to models that generate CoT before code generation \(Experiment 2\)\. Overall,INSIDEachieves the highest alignment across both settings\. Ontest\_OP, Qwen2\.5\-7B\-INSIDE reaches 51\.8%, outperforming the best prompting baseline, Qwen2\.5\-7B\-Instruct\-BloomCoT\. Ontest\_NP, Qwen3\-8B\-INSIDE achieves 57\.9% compared to 56\.0% for the strongest BloomCoT model\. Although scores ontest\_NPare higher overall, this split contains substantially fewer samples, resulting in larger standard errors \(≈\\approx2\.0–2\.3 vs\.≈\\approx0\.8–0\.9\), which limits direct comparison across settings\. Interestingly, larger and more capable models \(e\.g\., GPT\-5 and Qwen3\-32B\) tend to achieve lower alignment scores, suggesting that stronger reasoning ability does not necessarily translate to reasoning that matches student\-like code edits\. We additionally report self\-consistency results, measuring alignment between generated internal dialogue and model\-generated code, in[Appendix C](https://arxiv.org/html/2608.10492#A3)\.

Furthermore, alignment should be interpreted jointly with action fidelity\. High alignment alone does not indicate realistic student modeling if the generated code does not follow plausible solution trajectories\. This is a challenging task: the model must generate reasoning that aligns with specific code edits, rather than producing plausible but generic explanations\. While some prompting\-based models show alignment comparable toINSIDE\(e\.g\., Qwen2\.5\-7B\-Instruct\-BloomCoT ontest\_OP\), as shown in[Section 5\.1](https://arxiv.org/html/2608.10492#S5.SS1), these models exhibit poor action fidelity and unrealistic solution trajectories, indicating a disconnect between explanation and behavior\. In contrast,INSIDEachieves both high alignment and strong action fidelity, producing reasoning that is consistent with the observed edits while also generating code that follows realistic student progression\. This joint improvement suggests that internal dialogue helps bridge the gap between explanation and behavior, rather than optimizing for alignment alone\. We provide qualitative examples of model\-generated internal dialogue in Appendix[H](https://arxiv.org/html/2608.10492#A8)\.

## 6Limitations and Future Work

A key limitation of our approach is that internal dialogue is reconstructed rather than observed\. The reasoning traces are generated by a teacher LLM through retrospective inference, and therefore represent an approximation of the student’s latent cognition\. Importantly, because LLMs are typically trained to produce expert\-like reasoning, they may struggle to faithfully reconstruct novice reasoning patterns, even in a reconstruction setting\. As a result, the generated traces may reflect more coherent or structured reasoning than what real students exhibit\. While this provides a useful proxy, it remains a best\-effort estimate of what the student might have been thinking\. Future work can further validate and calibrate these reconstructed traces through human\-centered methods such as think\-aloud studies or retrospective verbalization protocols\.

Our evaluation also has a distributional limitation: the splits betweentest\_OPandtest\_NPdiffer not only in whether problems are seen or unseen, but also in their underlying student pass\-rate distributions, which can affect the interpretation of the results\. Additionally, whileINSIDEachieves the highest alignment among models \(reaching∼\\sim58%\), this shows that a majority of generated claims explain student code edits, with remaining gaps indicating room for further improvement\.

Moreover, compared to the near\-perfect alignment of teacher\-generated traces, this suggests opportunities to better capture reasoning that consistently accounts for student actions\. Future work can explore alternative approaches to reasoning generation, such as reinforcement learning methods\(Wuet al\.,[2026](https://arxiv.org/html/2608.10492#bib.bib11)\), which encourage reasoning to emerge through reward modeling rather than supervised fine\-tuning\.

Despite these limitations, incorporating internal dialogue does not degrade action fidelity compared to SFT\. Ontest\_OP,INSIDEmore closely matches student behavior, and ontest\_NP, performance remains comparable\. This highlights a key affordance of student simulators: beyond replicating behavior, they provide access to otherwise unobservable signals—internal dialogue\. This enables new applications in educational systems\. Student simulators are increasingly used to evaluate and optimize AI tutors prior to deployment\(Dinucu\-Jianuet al\.,[2025](https://arxiv.org/html/2608.10492#bib.bib188)\)\. By modeling both actions and reasoning,INSIDEallows evaluating whether feedback resolves misconceptions and supports counterfactual analysis of alternative interventions\. Beyond evaluation,INSIDEenables learner\-facing tools\. Externalizing internal dialogue can support reflection and metacognition\(Kumaret al\.,[2024](https://arxiv.org/html/2608.10492#bib.bib189)\), and provide richer student representations for clustering based on reasoning patterns rather than noisy surface behavior\(Luet al\.,[2025](https://arxiv.org/html/2608.10492#bib.bib187)\)\.

## 7Conclusion

We presentedINSIDE, a student simulation framework that jointly models student actions and internal reasoning\. Incorporating internal dialogue improves alignment with student behavior and achieves the highest reasoning quality among methods\. Thus, modeling reasoning beyond observable actions is key to building more realistic student simulators and enables new opportunities for evaluating and improving tutoring systems\. Beyond observed outcome simulation fidelity,INSIDEpoints to LLM\-based simulations grounded in cognitively plausible internal reasoning, presenting opportunities for developing tutoring systems equipped with misconception\-aware interventions\.

## References

- J\. R\. Anderson, A\. T\. Corbett, K\. R\. Koedinger, and R\. Pelletier \(1995\)Cognitive tutors: lessons learned\.InThe Journal of the Learning Sciences,Vol\.4,pp\. 167–207\.Cited by:[§2\.3](https://arxiv.org/html/2608.10492#S2.SS3.p1.1)\.
- L\. W\. Anderson, D\. R\. Krathwohl, P\. W\. Airasian, K\. A\. Cruikshank, R\. E\. Mayer, P\. R\. Pintrich, J\. Raths, and M\. C\. Wittrock \(2001\)A taxonomy for learning, teaching, and assessing: a revision of Bloom’s taxonomy of educational objectives\.Longman,New York\.Cited by:[§2\.3](https://arxiv.org/html/2608.10492#S2.SS3.p1.1)\.
- L\. P\. Argyle, E\. C\. Busby, N\. Fulda, J\. R\. Gubler, C\. Rytting, and D\. Wingate \(2023\)Out of one, many: using language models to simulate human samples\.Political Analysis31\(3\),pp\. 337–351\.Cited by:[§2\.1](https://arxiv.org/html/2608.10492#S2.SS1.p1.1)\.
- C\. A\. Bail, D\. S\. Hillygus, A\. Volfovsky, M\. Allamong, F\. Alqabandi, D\. M\. Jordan, G\. Tierney, C\. Tucker, A\. Trexler, and A\. van Loon \(2023\)Do we need a social media accelerator?\.SocArXiv doi10\.Cited by:[§2\.1](https://arxiv.org/html/2608.10492#S2.SS1.p1.1)\.
- B\. S\. Bloom, M\. D\. Engelhart, E\. J\. Furst, W\. H\. Hill, and D\. R\. Krathwohl \(1956\)Taxonomy of educational objectives: the classification of educational goals\. handbook I: cognitive domain\.David McKay Company,New York\.Cited by:[Appendix E](https://arxiv.org/html/2608.10492#A5.p1.1),[§2\.3](https://arxiv.org/html/2608.10492#S2.SS3.p1.1),[§3\.3](https://arxiv.org/html/2608.10492#S3.SS3.p4.1)\.
- J\. S\. Brown and R\. R\. Burton \(1978\)Diagnostic models for procedural bugs in basic mathematical skills\.Cognitive science2\(2\),pp\. 155–192\.Cited by:[§1](https://arxiv.org/html/2608.10492#S1.p2.1)\.
- A\. T\. Corbett and J\. R\. Anderson \(1994\)Knowledge tracing: modeling the acquisition of procedural knowledge\.User Modeling and User\-Adapted Interaction4\(4\),pp\. 253–278\.Cited by:[§2\.3](https://arxiv.org/html/2608.10492#S2.SS3.p1.1)\.
- D\. Dinucu\-Jianu, J\. Macina, N\. Daheim, I\. Hakimi, I\. Gurevych, and M\. Sachan \(2025\)From problem\-solving to teaching problem\-solving: aligning llms with pedagogy using reinforcement learning\.InProceedings of the 2025 Conference on Empirical Methods in Natural Language Processing,pp\. 272–292\.Cited by:[§6](https://arxiv.org/html/2608.10492#S6.p4.1)\.
- K\. A\. Ericsson and H\. A\. Simon \(1993\)Protocol analysis: verbal reports as data\.MIT Press\.Cited by:[§1](https://arxiv.org/html/2608.10492#S1.p2.1)\.
- G\. Fatouros, K\. Metaxas, J\. Soldatos, and D\. Kyriazis \(2024\)Can large language models beat wall street? unveiling the potential of ai in stock selection\.Unveiling the Potential of AI in Stock Selection \(January 13, 2024\)\.Cited by:[§2\.1](https://arxiv.org/html/2608.10492#S2.SS1.p1.1)\.
- D\. Guo, D\. Yang, H\. Zhang,et al\.\(2025\)DeepSeek\-R1: incentivizing reasoning capability in LLMs via reinforcement learning\.arXiv preprint arXiv:2501\.12948\.Cited by:[§2\.2](https://arxiv.org/html/2608.10492#S2.SS2.p1.1)\.
- J\. Hartmann, J\. Schwenzow, and M\. Witte \(2023\)The political ideology of conversational ai: converging evidence on chatgpt’s pro\-environmental, left\-libertarian orientation\.arXiv preprint arXiv:2301\.01768\.Cited by:[§2\.1](https://arxiv.org/html/2608.10492#S2.SS1.p1.1)\.
- A\. Hilliard, C\. Munoz, Z\. Wu, and A\. S\. Koshiyama \(2024\)Eliciting personality traits in large language models\.arXiv preprint arXiv:2402\.08341\.Cited by:[§2\.1](https://arxiv.org/html/2608.10492#S2.SS1.p1.1)\.
- J\. J\. Horton \(2023\)Large language models as simulated economic agents: what can we learn from homo silicus?\.Technical reportNational Bureau of Economic Research\.Cited by:[§2\.1](https://arxiv.org/html/2608.10492#S2.SS1.p1.1)\.
- E\. J\. Hu, yelong shen, P\. Wallis, Z\. Allen\-Zhu, Y\. Li, S\. Wang, L\. Wang, and W\. Chen \(2022\)LoRA: low\-rank adaptation of large language models\.InInternational Conference on Learning Representations,External Links:[Link](https://openreview.net/forum?id=nZeVKeeFYf9)Cited by:[1st item](https://arxiv.org/html/2608.10492#S3.I1.i1.p1.3)\.
- T\. Huber and C\. Niklaus \(2025\)LLMs meet Bloom’s taxonomy: a cognitive view on large language model evaluations\.InProceedings of the 31st International Conference on Computational Linguistics,pp\. 5211–5246\.Cited by:[§2\.3](https://arxiv.org/html/2608.10492#S2.SS3.p1.1)\.
- B\. Hui, J\. Yang, Z\. Cui, J\. Yang, D\. Liu, L\. Zhang, T\. Liu, J\. Zhang, B\. Yu, K\. Lu,et al\.\(2024\)Qwen2\.5\-coder technical report\.arXiv preprint arXiv:2409\.12186\.Cited by:[1st item](https://arxiv.org/html/2608.10492#S3.I1.i1.p1.3)\.
- P\. N\. Johnson\-Laird \(2010\)Mental models and human reasoning\.Proceedings of the National Academy of Sciences107\(43\),pp\. 18243–18250\.Cited by:[§1](https://arxiv.org/html/2608.10492#S1.p2.1)\.
- M\. Kang, S\. Moon, S\. H\. Lee, A\. Raj, J\. Suh, and D\. M\. Chan \(2025\)Deep binding of language model virtual personas: a study on approximating political partisan misperceptions\.InProceedings of the Conference on Language Modeling \(COLM\),Cited by:[§2\.2](https://arxiv.org/html/2608.10492#S2.SS2.p1.1)\.
- M\. Khalil, F\. Vadiee, R\. Shakya, and Q\. Liu \(2025\)Creating artificial students that never existed: leveraging large language models and cTGANs for synthetic data generation\.InProceedings of the 15th International Learning Analytics and Knowledge Conference,pp\. 439–450\.Cited by:[§1](https://arxiv.org/html/2608.10492#S1.p1.1),[§2\.1](https://arxiv.org/html/2608.10492#S2.SS1.p2.1)\.
- T\. Kojima, S\. S\. Gu, M\. Reid, Y\. Matsuo, and Y\. Iwasawa \(2022\)Large language models are zero\-shot reasoners\.InAdvances in Neural Information Processing Systems,Vol\.35,pp\. 22199–22213\.Cited by:[§2\.2](https://arxiv.org/html/2608.10492#S2.SS2.p1.1)\.
- H\. Kumar, R\. Xiao, B\. Lawson, I\. Musabirov, J\. Shi, X\. Wang, H\. Luo, J\. J\. Williams, A\. N\. Rafferty, J\. Stamper,et al\.\(2024\)Supporting self\-reflection at scale with large language models: insights from randomized field experiments in classrooms\.InProceedings of the eleventh ACM conference on learning@ scale,pp\. 86–97\.Cited by:[§6](https://arxiv.org/html/2608.10492#S6.p4.1)\.
- J\. Leinonen, P\. Denny, O\. Kiljunen, S\. MacNeil, S\. Sarsa, and A\. Hellas \(2025\)LLM\-itation is the sincerest form of data: generating synthetic buggy code submissions for computing education\.InProceedings of the 27th Australasian Computing Education Conference,ACE ’25,pp\. 56–63\.External Links:ISBN 9798400714252,[Link](https://doi.org/10.1145/3716640.3716647),[Document](https://dx.doi.org/10.1145/3716640.3716647)Cited by:[Figure 7](https://arxiv.org/html/2608.10492#A6.F7)\.
- C\. J\. Li, J\. Wu, Z\. Mo, A\. Qu, Y\. Tang, K\. Zhao, Y\. Gan, J\. Fan, J\. Yu, J\. Zhao,et al\.\(2026\)Simulating society requires simulating thought\.Advances in Neural Information Processing Systems38\.Cited by:[§1](https://arxiv.org/html/2608.10492#S1.p1.1)\.
- Y\. Lu, S\. Yeom, J\. Maktoubian, M\. M\. Rahman, and S\. Kim \(2025\)Improve student risk prediction with clustering techniques: a systematic review in education data mining\.Education Sciences15\(12\),pp\. 1695\.Cited by:[§6](https://arxiv.org/html/2608.10492#S6.p4.1)\.
- J\. Macina, N\. Daheim, S\. Chowdhury, T\. Sinha, M\. Kapur, I\. Gurevych, and M\. Sachan \(2023\)Mathdial: a dialogue tutoring dataset with rich pedagogical properties grounded in math reasoning problems\.InFindings of the Association for Computational Linguistics: EMNLP 2023,pp\. 5602–5621\.Cited by:[§1](https://arxiv.org/html/2608.10492#S1.p1.1)\.
- J\. M\. Markel, S\. G\. Opferman, J\. A\. Landay, and C\. Piech \(2023\)GPTeach: interactive TA training with GPT\-based students\.InProceedings of the Tenth ACM Conference on Learning @ Scale,pp\. 226–236\.Cited by:[§1](https://arxiv.org/html/2608.10492#S1.p1.1),[§2\.1](https://arxiv.org/html/2608.10492#S2.SS1.p2.1)\.
- Meta \(2024\)Meta Llama 3\.External Links:[Link](https://llama.meta.com/llama3/)Cited by:[1st item](https://arxiv.org/html/2608.10492#S3.I1.i1.p1.3)\.
- M\. Miroyan, R\. Niousha, J\. E\. Gonzalez, G\. Ranade, and N\. Norouzi \(2025\)ParaStudent: generating and evaluating realistic student code by teaching LLMs to struggle\.arXiv preprint arXiv:2507\.12674\.Cited by:[§1](https://arxiv.org/html/2608.10492#S1.p1.1),[§2\.1](https://arxiv.org/html/2608.10492#S2.SS1.p2.1),[§4\.1](https://arxiv.org/html/2608.10492#S4.SS1.p1.1)\.
- S\. Moon, M\. Abdulhai, M\. Kang, J\. Suh, W\. Soedarmadji, E\. K\. Behar, and D\. M\. Chan \(2024\)Virtual personas for language models via an anthology of backstories\.InProceedings of the 2024 conference on empirical methods in natural language processing,pp\. 19864–19897\.Cited by:[§2\.2](https://arxiv.org/html/2608.10492#S2.SS2.p1.1)\.
- R\. E\. Noonan \(1985\)An algorithm for generating abstract syntax trees\.Comput\. Lang\.10\(3–4\),pp\. 225–236\.External Links:ISSN 0096\-0551,[Link](https://doi.org/10.1016/0096-0551(85)90018-9),[Document](https://dx.doi.org/10.1016/0096-0551%2885%2990018-9)Cited by:[2nd item](https://arxiv.org/html/2608.10492#S4.I1.i2.p1.1)\.
- OpenAI \(2025\)GPT\-5 is here\.External Links:[Link](https://openai.com/gpt-5/)Cited by:[§3\.3](https://arxiv.org/html/2608.10492#S3.SS3.p4.1)\.
- J\. S\. Park, J\. O’Brien, C\. J\. Cai, M\. R\. Morris, P\. Liang, and M\. S\. Bernstein \(2023\)Generative agents: interactive simulacra of human behavior\.InProceedings of the 36th annual acm symposium on user interface software and technology,pp\. 1–22\.Cited by:[§2\.1](https://arxiv.org/html/2608.10492#S2.SS1.p1.1)\.
- J\. S\. Park, C\. Q\. Zou, A\. Shaw, B\. M\. Hill, C\. Cai, M\. R\. Morris, R\. Willer, P\. Liang, and M\. S\. Bernstein \(2024\)Generative agent simulations of 1,000 people\.arXiv preprint arXiv:2411\.10109\.Cited by:[§1](https://arxiv.org/html/2608.10492#S1.p1.1),[§2\.1](https://arxiv.org/html/2608.10492#S2.SS1.p1.1)\.
- C\. Piech, J\. Bassen, J\. Huang, S\. Ganguli, M\. Sahami, L\. J\. Guibas, and J\. Sohl\-Dickstein \(2015\)Deep knowledge tracing\.InAdvances in Neural Information Processing Systems,Vol\.28\.Cited by:[§2\.3](https://arxiv.org/html/2608.10492#S2.SS3.p1.1)\.
- C\. Qian, A\. T\. Parisi, C\. Bouleau, V\. Tsai, M\. Lebreton, and L\. Dixon \(2025\)To mask or to mirror: human\-ai alignment in collective reasoning\.InProceedings of the 2025 Conference on Empirical Methods in Natural Language Processing,pp\. 2398–2423\.Cited by:[§2\.1](https://arxiv.org/html/2608.10492#S2.SS1.p1.1)\.
- A\. Ross and J\. Andreas \(2025\)Learning to make mistakes: modeling incorrect student thinking and key errors\.arXiv preprint arXiv:2510\.11502\.Cited by:[§1](https://arxiv.org/html/2608.10492#S1.p4.1)\.
- A\. Ross, M\. Srivastava, J\. Blanchard, and J\. Andreas \(2026\)Modeling student learning with 3\.8 million program traces\.InArtificial Intelligence in Education: 27th International Conference, AIED 2026, Seoul, South Korea, June 27–July 3, 2026, Proceedings, Part II,Berlin, Heidelberg,pp\. 324–338\.External Links:ISBN 978\-3\-032\-29754\-9,[Link](https://doi.org/10.1007/978-3-032-29755-6_22),[Document](https://dx.doi.org/10.1007/978-3-032-29755-6%5F22)Cited by:[§1](https://arxiv.org/html/2608.10492#S1.p1.1)\.
- S\. Santurkar, E\. Durmus, F\. Ladhak, C\. Lee, P\. Liang, and T\. Hashimoto \(2023\)Whose opinions do language models reflect?\.InInternational Conference on Machine Learning,pp\. 29971–30004\.Cited by:[§2\.1](https://arxiv.org/html/2608.10492#S2.SS1.p1.1)\.
- G\. Serapio\-García, M\. Safdari, C\. Crepy, L\. Sun, S\. Fitz, P\. Romero, M\. Abdulhai, A\. Faust, and M\. Matarić \(2023\)Personality traits in large language models\.arXiv preprint arXiv:2307\.00184\.Cited by:[§2\.1](https://arxiv.org/html/2608.10492#S2.SS1.p1.1)\.
- Z\. Shao, P\. Wang, Q\. Zhu, R\. Xu, J\. Song, X\. Bi, H\. Zhang, M\. Zhang, Y\. Li, Y\. Wu,et al\.\(2024\)Deepseekmath: pushing the limits of mathematical reasoning in open language models\.arXiv preprint arXiv:2402\.03300\.Cited by:[§1](https://arxiv.org/html/2608.10492#S1.p3.1),[§2\.2](https://arxiv.org/html/2608.10492#S2.SS2.p1.1)\.
- G\. Simmons \(2023\)Moral mimicry: large language models produce moral rationalizations tailored to political identity\.InProceedings of the 61st Annual Meeting of the Association for Computational Linguistics \(Volume 4: Student Research Workshop\),V\. Padmakumar, G\. Vallejo, and Y\. Fu \(Eds\.\),Toronto, Canada,pp\. 282–297\.External Links:[Link](https://aclanthology.org/2023.acl-srw.40/),[Document](https://dx.doi.org/10.18653/v1/2023.acl-srw.40)Cited by:[§2\.1](https://arxiv.org/html/2608.10492#S2.SS1.p1.1)\.
- K\. E\. Stanovich and R\. F\. West \(2000\)Advancing the rationality debate\.Behavioral and brain sciences23\(5\),pp\. 701–717\.Cited by:[§1](https://arxiv.org/html/2608.10492#S1.p2.1)\.
- J\. Suh, E\. Jahanparast, S\. Moon, M\. Kang, and S\. Chang \(2025\)Language model fine\-tuning on scaled survey data for predicting distributions of public opinions\.InProceedings of the 63rd Annual Meeting of the Association for Computational Linguistics \(Volume 1: Long Papers\),pp\. 21147–21170\.Cited by:[§1](https://arxiv.org/html/2608.10492#S1.p1.1),[§2\.1](https://arxiv.org/html/2608.10492#S2.SS1.p1.1)\.
- Y\. Tseng, Y\. Huang, T\. Hsiao, W\. Chen, C\. Huang, Y\. Meng, and Y\. Chen \(2024\)Two tales of persona in LLMs: a survey of role\-playing and personalization\.InFindings of the Association for Computational Linguistics: EMNLP 2024,pp\. 16612–16631\.Cited by:[§2\.1](https://arxiv.org/html/2608.10492#S2.SS1.p2.1)\.
- G\. van Rossum, B\. Warsaw, and A\. Coghlan \(2025\)PEP 8 – style guide for python code\.External Links:[Link](https://peps.python.org/pep-0008/)Cited by:[3rd item](https://arxiv.org/html/2608.10492#S4.I1.i3.p1.1)\.
- J\. Wei, X\. Wang, D\. Schuurmans, M\. Bosma, E\. Chi, Q\. Le, and D\. Zhou \(2022\)Chain\-of\-thought prompting elicits reasoning in large language models\.InAdvances in Neural Information Processing Systems,Vol\.35,pp\. 24824–24837\.Cited by:[§1](https://arxiv.org/html/2608.10492#S1.p3.1),[§2\.2](https://arxiv.org/html/2608.10492#S2.SS2.p1.1)\.
- P\. Y\. Wu, J\. Nagler, J\. A\. Tucker, and S\. Messing \(2023\)Large language models can be used to scale the ideologies of politicians in a zero\-shot learning setting\.External Links:2303\.12057Cited by:[§2\.1](https://arxiv.org/html/2608.10492#S2.SS1.p1.1)\.
- S\. Wu, E\. Choi, A\. Khatua, Z\. Wang, J\. He\-Yueya, T\. C\. Weerasooriya, W\. Wei, D\. Yang, J\. Leskovec, and J\. Zou \(2026\)HumanLM: simulating users with state alignment beats response imitation\.InProceedings of the International Conference on Machine Learning \(ICML\),Cited by:[§1](https://arxiv.org/html/2608.10492#S1.p1.1),[§2\.2](https://arxiv.org/html/2608.10492#S2.SS2.p1.1),[§6](https://arxiv.org/html/2608.10492#S6.p3.1)\.
- S\. Xu, X\. Zhang,et al\.\(2025\)Classroom simulacra: building contextual student generative agents in online education for learning behavioral simulation\.InProceedings of the CHI Conference on Human Factors in Computing Systems,Cited by:[§1](https://arxiv.org/html/2608.10492#S1.p1.1),[§2\.1](https://arxiv.org/html/2608.10492#S2.SS1.p2.1)\.
- A\. Yang, A\. Li, B\. Yang, B\. Zhang, B\. Hui, B\. Zheng, B\. Yu, C\. Gao, C\. Huang, C\. Lv,et al\.\(2025a\)Qwen3 technical report\.arXiv preprint arXiv:2505\.09388\.Cited by:[§2\.2](https://arxiv.org/html/2608.10492#S2.SS2.p1.1),[1st item](https://arxiv.org/html/2608.10492#S3.I1.i1.p1.3)\.
- A\. Yang, B\. Yang, B\. Zhang, B\. Hui, B\. Zheng, B\. Yu, C\. Li, D\. Liu, F\. Huang, H\. Wei, H\. Lin, J\. Yang, J\. Tu, J\. Zhang, J\. Yang, J\. Yang, J\. Zhou, J\. Lin, K\. Dang, K\. Lu, K\. Bao, K\. Yang, L\. Yu, M\. Li, M\. Xue, P\. Zhang, Q\. Zhu, R\. Men, R\. Lin, T\. Li, T\. Tang, T\. Xia, X\. Ren, X\. Ren, Y\. Fan, Y\. Su, Y\. Zhang, Y\. Wan, Y\. Liu, Z\. Cui, Z\. Zhang, and Z\. Qiu \(2025b\)Qwen2\.5 technical report\.External Links:2412\.15115,[Link](https://arxiv.org/abs/2412.15115)Cited by:[1st item](https://arxiv.org/html/2608.10492#S3.I1.i1.p1.3)\.
- Q\. Yang, Z\. Wang, H\. Chen, S\. Wang, Y\. Pu, X\. Gao, W\. Huang, S\. Song, and G\. Huang \(2024\)PsychoGAT: a novel psychological measurement paradigm through interactive fiction games with LLM agents\.InProceedings of the 62nd Annual Meeting of the Association for Computational Linguistics \(Volume 1: Long Papers\),L\. Ku, A\. Martins, and V\. Srikumar \(Eds\.\),Bangkok, Thailand,pp\. 14470–14505\.External Links:[Link](https://aclanthology.org/2024.acl-long.779/),[Document](https://dx.doi.org/10.18653/v1/2024.acl-long.779)Cited by:[§1](https://arxiv.org/html/2608.10492#S1.p1.1)\.
- S\. Yao, D\. Yu, J\. Zhao, I\. Shafran, T\. Griffiths, Y\. Cao, and K\. Narasimhan \(2023a\)Tree of thoughts: deliberate problem solving with large language models\.Advances in neural information processing systems36,pp\. 11809–11822\.Cited by:[§1](https://arxiv.org/html/2608.10492#S1.p3.1)\.
- S\. Yao, J\. Zhao, D\. Yu, N\. Du, I\. Shafran, K\. R\. Narasimhan, and Y\. Cao \(2023b\)React: synergizing reasoning and acting in language models\.InThe eleventh international conference on learning representations,Cited by:[§2\.2](https://arxiv.org/html/2608.10492#S2.SS2.p1.1)\.
- M\. Yue, W\. Mifdal, Y\. Zhang, J\. Suh, and Z\. Yao \(2024\)MathVC: an LLM\-simulated multi\-character virtual classroom for mathematics education\.InarXiv preprint arXiv:2404\.06711,Cited by:[§2\.1](https://arxiv.org/html/2608.10492#S2.SS1.p2.1)\.
- J\.D\. Zamfirescu\-Pereira, L\. Qi, B\. Hartmann, J\. DeNero, and N\. Norouzi \(2025\)61A bot report: ai assistants in cs1 save students homework time and reduce demands on staff\. \(now what?\)\.InProceedings of the 56th ACM Technical Symposium on Computer Science Education V\. 1,SIGCSETS 2025,New York, NY, USA,pp\. 1309–1315\.External Links:ISBN 9798400705311,[Link](https://doi.org/10.1145/3641554.3701864),[Document](https://dx.doi.org/10.1145/3641554.3701864)Cited by:[§3\.1](https://arxiv.org/html/2608.10492#S3.SS1.p1.2)\.
- D\. Zhou, N\. Schärli, L\. Hou, J\. Wei, N\. Scales, X\. Wang, D\. Schuurmans, C\. Cui, O\. Bousquet, Q\. V\. Le,et al\.\(2022\)Least\-to\-most prompting enables complex reasoning in large language models\.InThe eleventh international conference on learning representations,Cited by:[§2\.2](https://arxiv.org/html/2608.10492#S2.SS2.p1.1)\.

## Appendix AData Privacy

We received IRB approval for the research use of the dataset \(protocol ID: 2023\-09\-16725\), after which the AI tutor was deployed in the course\. When students submitted their code to the autograder as part of the regular course practice, they were asked whether they would like to receive AI tutor feedback on their code, and if so, were asked whether they would like their data to be used for research\. Students were still able to receive AI feedback even if they did not wish their data to be used in research\. Only students who explicitly consented were included in our analysis\. Additionally, all student identifiers \(e\.g\., IDs and emails\) were fully anonymized prior to passing the data to the LLM and any further analysis\. As part of our system design, any data from LLM calls from our educational platform to the model providers will not be retained on third\-party servers and will not be used for further fine\-tuning of those models\.

## Appendix BExtended Action Fidelity Results

This section provides extended results that complement the main paper\. First, we report results ontest\_OP\_2andtest\_NP\_2to evaluate model performance on additional test problems\. The progression of pass rate is shown in[Figure 3](https://arxiv.org/html/2608.10492#A2.F3), exhibiting trends consistent withtest\_OP\_1andtest\_NP\_1\. Second, we report additional results for LLaMA and its Wasserstein distance metrics in[Table 3](https://arxiv.org/html/2608.10492#A2.T3)\.

![Refer to caption](https://arxiv.org/html/2608.10492v1/x4.png)\(a\)test\_OP\_2\(Representative Problem:n=759n=759\)
![Refer to caption](https://arxiv.org/html/2608.10492v1/x5.png)\(b\)test\_NP\_2\(Representative Problem:n=359n=359\)

Figure 3:Pass rate trajectories over normalized submission steps ontest\_OP\_2andtest\_NP\_2\.Table 3:LLaMA results \(Wasserstein distances\)\.
## Appendix CSelf\-Consistency of the Models

[Table 4](https://arxiv.org/html/2608.10492#A3.T4)reports self\-consistency, a variant of the alignment metric described in[Section 4\.2](https://arxiv.org/html/2608.10492#S4.SS2), measuring alignment between generated internal dialogue and the model’s own generated code\. Formally, we replace the ground\-truth transitionct−1,si,pu→ct,si,puc\_\{t\-1,s\_\{i\},p\_\{u\}\}\\rightarrow c\_\{t,s\_\{i\},p\_\{u\}\}with the model\-generated transitionct−1,si,pu→c^t,si,puc\_\{t\-1,s\_\{i\},p\_\{u\}\}\\rightarrow\\hat\{c\}\_\{t,s\_\{i\},p\_\{u\}\}and compute

SelfConsistencyt=1\|𝒱t\|​∑i=1\|𝒱t\|𝟙self​\(v\(i\)\),\\texttt\{SelfConsistency\}\_\{t\}=\\frac\{1\}\{\|\\mathcal\{V\}\_\{t\}\|\}\\sum\_\{i=1\}^\{\|\\mathcal\{V\}\_\{t\}\|\}\\mathbb\{1\}\_\{\\mathrm\{self\}\}\(v^\{\(i\)\}\),where𝟙self​\(v\(i\)\)=1\\mathbb\{1\}\_\{\\mathrm\{self\}\}\(v^\{\(i\)\}\)=1if claimv\(i\)v^\{\(i\)\}is reflected in the model\-generated code diff and0otherwise\.

Prompting\-based models achieve high self\-consistency scores \(86\.9%–99\.0% across both test sets\), with GPT\-5 attaining the highest scores\. However, as shown in our action fidelity evaluation \([Section 5\.1](https://arxiv.org/html/2608.10492#S5.SS1)\), GPT\-5 performs among the worst in terms of reproducing realistic student code trajectories\. Taken together, these results suggest that strong consistency between a model’s reasoning and its own generated code does not necessarily imply alignment with real student reasoning or behavior\. While prompting\-based methods naturally exhibit higher self\-consistency due to explicit CoT prompting,INSIDEalso achieves competitive self\-consistency \(83\.0%–87\.3% across both test sets\), indicating that its generated reasoning remains coherent with its generated code while better matching real student code edits\.

Table 4:Self\-consistency between generated internal dialogue and model\-generated code\.Each cell reports self\-consistency \(%\) with standard error in parentheses\. Higher values indicate better agreement between the generated reasoning and the model’s own generated code\.\(a\)test\_OP
\(b\)test\_NP

## Appendix DStudent Pass\-Rate Distribution Across Test Splits

We compare empirical student and model pass\-rate distributions in[Figure 4](https://arxiv.org/html/2608.10492#A4.F4), since pass rate directly captures whether models generate submissions at student\-like correctness levels\.

Bothtest\_OPandtest\_NPstudent distributions are concentrated at the endpoints, with 83% and 81% of mass at pass rates 0 and 1, respectively\. However, their failure/success balance differs:test\_OPstudents fail at 55% and succeed at 28% \(roughly 2:1\), whereastest\_NPstudents fail at 47% and succeed at 34% \(roughly 1\.4:1\)\. This helps explain the smallerINSIDE–SFT gap ontest\_NP\. Ontest\_OP, SFT underestimates complete failure \(43% vs\. 55%\) and overestimates complete success \(40% vs\. 28%\), reflecting residual over\-competence from the base model;INSIDEbetter corrects this mismatch\. Ontest\_NP, where students fail less and succeed more, SFT is already closer to the student distribution, leaving less mismatch forINSIDEto correct\.

This also helps explain why Wasserstein distances are smaller ontest\_NP, especially for SFT\.[Figure 4](https://arxiv.org/html/2608.10492#A4.F4)suggests that SFT’s smaller pass\-rate Wasserstein distances ontest\_NPare driven largely by its close match to fully passing submissions\. Since fully correct solutions in introductory Python problems often share similar structure, including LOC, AST shape, and style, SFT’s calibration at pass rate 1\.0 can also reduce distances on related action\-fidelity metrics\.

![Refer to caption](https://arxiv.org/html/2608.10492v1/x6.png)Figure 4:Exact pass\-rate mass by split: Student vs\. SFT vs\. INSIDE\.Each panel shows the probability mass of student, SFT, and INSIDE submissions at each exact pass rate, faceted by test split \(test\_OPtop,test\_NPbottom\)\. Both splits show student distributions concentrated at the endpoints \(pass rate 0 or 1\), but differ in their failure/success ratio, which helps explain the asymmetric INSIDE–SFT gap across splits\.
## Appendix EInternal Dialogue Generation Prompt

We provide the full prompt used to generate synthetic internal dialogue with the teacher model in[Figure 5](https://arxiv.org/html/2608.10492#A5.F5)\. The prompt performs retrospective inference over real student prior code, feedback, and the observed next submission, producing structured cognitive, affective, and action states followed by a first\-person think trace inspired byBloomet al\.\([1956](https://arxiv.org/html/2608.10492#bib.bib32)\)\. These generated traces are used as supervision for trainingINSIDE\.

System Prompt[⬇](data:text/plain;base64,WW91IGFyZSBhbmFseXppbmcgYSBub3ZpY2Ugc3R1ZGVudCBpbnRlcmFjdGluZyB3aXRoIGFuIEFJIHByb2dyYW1taW5nIHR1dG9yIGFuZCByZWNvbnN0cnVjdGluZyB0aGUgaW50ZXJuYWwgZGlhbG9ndWUgYmVoaW5kIHRoZSBjb2RlIGVkaXRzIHRoZXkgbWFrZS4KClRoaXMgaXMgYSByZXRyb3NwZWN0aXZlIHJlY29uc3RydWN0aW9uIHRhc2suIFlvdSBhcmUgZ2l2ZW46Ci0gdGhlIGZ1bGwgcGFzdCBpbnRlcmFjdGlvbiBoaXN0b3J5LCBpbmNsdWRpbmcgcHJldmlvdXNseSBpbmZlcnJlZCBzdHVkZW50IGRpYWxvZ3VlCi0gdGhlIG1vc3QgcmVjZW50IHN1Ym1pc3Npb24gYW5kIHRoZSBmZWVkYmFjayBvbiB0aGF0IHN1Ym1pc3Npb24KLSB0aGUgc3Vic2VxdWVudCBzdWJtaXNzaW9uCgpTdHVkZW50cyBkaWZmZXIgaW4gYmFja2dyb3VuZCwgZXhwZXJpZW5jZSwgY29uZmlkZW5jZSwgYW5k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Iprogrammingtutorandreconstructingtheinternaldialoguebehindthecodeeditstheymake\.Thisisaretrospectivereconstructiontask\.Youaregiven:\-thefullpastinteractionhistory,includingpreviouslyinferredstudentdialogue\-themostrecentsubmissionandthefeedbackonthatsubmission\-thesubsequentsubmissionStudentsdifferinbackground,experience,confidence,andproblem\-solvingstyle\.Theymaymisunderstandfeedback,partiallyapplyit,over\-applyit,orignorepartsofit\.Theyoftenmakesmalllocaleditsinsteadoffullyrestructuringtheircode\.Yourtaskhastwosteps\.\#\#\#STEP1:Inferthestudent’sinternalstatefromthecontext\.Writethesefieldsfromathird\-personanalystperspectivedescribingthestudent,notinthestudent’sownvoice\.Thestatescorrespondtothreelearningdimensionscommonlyusedineducationaltheory:cognitive\(knowledgeandreasoning\),affective\(emotionsandattitudestowardlearning\),andaction\(theconcreteproblem\-solvingstepthestudentistaking\)\.Useexactlythesetags:<cognitive\>Inonesentence,describethestudent’scurrentunderstandingoftheproblemorfeedback\.Thismayincluderecallingrelevantconcepts,interpretingthefeedback,applyingarule,analyzingthecauseofabug,orformingahypothesisabouthowtofixthecode\.Includebothcorrectandincorrectbeliefsormisconceptionssuggestedbythecodechanges\.</cognitive\><affective\>Inonesentence,describethestudent’semotionalormotivationalstatetowardthetask,suchasconfusion,uncertainty,frustration,confidence,curiosity,orpersistence\.Thisreflectshowthestudentisreactingtothefeedbackandthedifficultyoftheproblem\.</affective\><action\>Inonesentence,describetheconcreteprogrammingstepthestudentappearstotakenextbasedonthesubsequentsubmission\.Thisshouldreflectthestudent’sproblem\-solvingaction\.</action\>\#\#\#STEP2:Generatethestudent’sinternaldialogue\.<think\>Writethestudent’sinternaldialogueinfirst\-personvoice,basedontheinferredstatesabove\(cognitive,affective,action\)\.Thedialogueshouldreflectwhatthestudentlikelythoughtbeforeproducingthesubsequentsubmission\(i\.e\.,the"voiceintheirhead"\)\.Itshouldreadlikeabriefthink\-aloudexplanationoftheirreasoning\.Thethoughtshouldsoundlikeanoviceprogrammerthinkingthroughtheproblem:informal,tentative,andsometimesincomplete\.Itmayincludeuncertainty,guesses,orsmallmisunderstandings,andmayoccasionallyincludequestionsthestudentasksthemselves\.</think\>Outputexactlyinthisformatandnothingelse:<cognitive\>\.\.\.</cognitive\><affective\>\.\.\.</affective\><action\>\.\.\.</action\><think\>\.\.\.</think\>

User Prompt[⬇](data:text/plain;base64,SGVyZSBpcyB0aGUgY29udGV4dCBmb3IgdGhlIHByb2JsZW0gdGhleSBhcmUgd29ya2luZyBvbjoKCltQcm9ibGVtIGluc3RydWN0aW9uc10Ke2lucFsiaW5zdHJ1Y3Rpb25zIl19CgpbU2tlbGV0b24gY29kZV0KCkZpeGVkOgp7aW5wWyJza2VsZXRvbl9jb2RlX2ZpeGVkIl19CgpUb2RvOgp7aW5wWyJza2VsZXRvbl9jb2RlX3RvZG8iXX0KCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQpQQVNUIElOVEVSQUNUSU9OIEhJU1RPUlkKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Cgp7cGFzdF9oaXN0b3J5fQoKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CkNVUlJFTlQgU1RFUAo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KCltTdHVkZW50IHN1Ym1pc3Npb25dCntjdXJyZW50X3ByZXZfc3VifQoKW0ZlZWRiYWNrIHRoZSBzdHVkZW50IGp1c3QgcmVjZWl2ZWRdCntjdXJyZW50X2ZifQoKW1N0dWRlbnQncyBzdWJzZXF1ZW50IHN1Ym1pc3Npb25dCntvdXRwdXR9)Hereisthecontextfortheproblemtheyareworkingon:\[Probleminstructions\]\{inp\["instructions"\]\}\[Skeletoncode\]Fixed:\{inp\["skeleton\_code\_fixed"\]\}Todo:\{inp\["skeleton\_code\_todo"\]\}==============================PASTINTERACTIONHISTORY==============================\{past\_history\}==============================CURRENTSTEP==============================\[Studentsubmission\]\{current\_prev\_sub\}\[Feedbackthestudentjustreceived\]\{current\_fb\}\[Student’ssubsequentsubmission\]\{output\}

Figure 5:Prompt used for internal dialogue generation from real student code submission traces to use for the fine\-tuning of INSIDE\.
## Appendix FStudent Code Simulation Prompts

We provide the prompt templates used across all settings: fine\-tuning \([Figure 6](https://arxiv.org/html/2608.10492#A6.F6)\), standard prompting without CoT \([Figure 7](https://arxiv.org/html/2608.10492#A6.F7)\), CoT prompting \([Figure 8](https://arxiv.org/html/2608.10492#A6.F8)\), and Bloom’s Taxonomy\-inspired structured CoT prompting \([Figure 9](https://arxiv.org/html/2608.10492#A6.F9)\)\.

[⬇](data:text/plain;base64,UFJPQkxFTSBJTlNUUlVDVElPTlM6CntpbnN0cnVjdGlvbnN9CgpGSVhFRCBDT0RFOgo8Y29kZT57Zml4ZWRfY29kZX08L2NvZGU+CgpUT0RPIENPREU6Cjxjb2RlPntza2VsZXRvbl9jb2RlfTwvY29kZT4KClNVQk1JU1NJT04gSElTVE9SWSAoQ09ERSArIEZFRURCQUNLKToKe3N1Ym1pc3Npb25zX3dpdGhfZmVlZGJhY2t9)PROBLEMINSTRUCTIONS:\{instructions\}FIXEDCODE:<code\>\{fixed\_code\}</code\>TODOCODE:<code\>\{skeleton\_code\}</code\>SUBMISSIONHISTORY\(CODE\+FEEDBACK\):\{submissions\_with\_feedback\}

Figure 6:Prompt template for fine\-tuned models\.The same template is used during both training and inference\. Given this input, SFT outputs only the next code submission \(<code\>\.\.\.</code\>\), whileINSIDEgenerates both internal dialogue \(<think\>\.\.\.</think\>\) and the next code \(<code\>\.\.\.</code\>\)\.System Prompt[⬇](data:text/plain;base64,WW91IGFyZSBzaW11bGF0aW5nIGEgc3R1ZGVudCB0YWtpbmcgYW4gaW50cm9kdWN0aW9uIHRvIFB5dGhvbiBwcm9ncmFtbWluZyBjb3Vyc2UuCkdlbmVyYXRlIHRoZSBzdHVkZW50J3MgbmV4dCBhdHRlbXB0IGF0IHRoZSBUT0RPIENPREUgb2YgdGhlIGN1cnJlbnQgcHJvYmxlbSwgdXNpbmcgYm90aCB0aGVpciBwcmlvciBzdWJtaXNzaW9ucyBhbmQgdGhlIGZlZWRiYWNrIHRoZXkgcmVjZWl2ZWQuCgotIFdoZW4gd3JpdGluZyB0aGUgY29kZSwgeW91IG11c3Qgd3JhcCB0aGUgZ2VuZXJhdGVkIGNvZGUgaW4gPGNvZGU+IGFuZCA8L2NvZGU+IHRhZ3MuCi0gT25seSB3cml0ZSB0aGUgY29udGVudHMgb2YgdGhlIFRPRE8gQ09ERS4gRG8gbm90IGluY2x1ZGUgZG9jc3RyaW5ncyBvciBhbnl0aGluZyBvdXRzaWRlIGl0LgotIEFzIGEgbm92aWNlIHN0dWRlbnQsIHlvdXIgYXR0ZW1wdHMgbWF5IGluY2x1ZGUgbWlzdGFrZXMgb3IgcGFydGlhbCBmaXhlcy4KLSBGSVhFRCBDT0RFIGlzIHByb3ZpZGVkIC0gZG8gbm90IGNvcHksIG1vZGlmeSwgb3IgaW5jbHVkZSBpdC4KLSBVc2UgcHJpb3IgZmVlZGJhY2sgdG8gaW5mb3JtIHlvdXIgY29kZSByZXZpc2lvbi4KLSBJZiB0aGUgZ2VuZXJhdGVkIGF0dGVtcHQgaXMgdGhlIHN0dWRlbnQncyBmaW5hbCBzdWJtaXNzaW9uLCBhcHBlbmQgIjxTVUJNSVQ+IiBhdCB0aGUgZW5kLgotIFVzZSB0aGUgUHl0aG9uIHByb2dyYW1taW5nIGxhbmd1YWdl)YouaresimulatingastudenttakinganintroductiontoPythonprogrammingcourse\.Generatethestudent’snextattemptattheTODOCODEofthecurrentproblem,usingboththeirpriorsubmissionsandthefeedbacktheyreceived\.\-Whenwritingthecode,youmustwrapthegeneratedcodein<code\>and</code\>tags\.\-OnlywritethecontentsoftheTODOCODE\.Donotincludedocstringsoranythingoutsideit\.\-Asanovicestudent,yourattemptsmayincludemistakesorpartialfixes\.\-FIXEDCODEisprovided\-donotcopy,modify,orincludeit\.\-Usepriorfeedbacktoinformyourcoderevision\.\-Ifthegeneratedattemptisthestudent’sfinalsubmission,append"<SUBMIT\>"attheend\.\-UsethePythonprogramminglanguage

User Prompt[⬇](data:text/plain;base64,UFJPQkxFTSBJTlNUUlVDVElPTlM6CntpbnN0cnVjdGlvbnN9CgpGSVhFRCBDT0RFOgo8Y29kZT57Zml4ZWRfY29kZX08L2NvZGU+CgpUT0RPIENPREU6Cjxjb2RlPntza2VsZXRvbl9jb2RlfTwvY29kZT4KClNVQk1JU1NJT04gSElTVE9SWSAoQ09ERSArIEZFRURCQUNLKToKe3N1Ym1pc3Npb25zX3dpdGhfZmVlZGJhY2t9)PROBLEMINSTRUCTIONS:\{instructions\}FIXEDCODE:<code\>\{fixed\_code\}</code\>TODOCODE:<code\>\{skeleton\_code\}</code\>SUBMISSIONHISTORY\(CODE\+FEEDBACK\):\{submissions\_with\_feedback\}

Figure 7:Prompt template for prompting models without CoT\.The model is instructed to generate only the next code submission \(<code\>\.\.\.</code\>\)\. These prompts are adapted from prior work\(Leinonenet al\.,[2025](https://arxiv.org/html/2608.10492#bib.bib181)\), which used LLMs to mimic the distribution of error types and test case failure frequencies of real student datasets\.System Prompt[⬇](data:text/plain;base64,WW91IGFyZSBzaW11bGF0aW5nIGEgc3R1ZGVudCB0YWtpbmcgYW4gaW50cm9kdWN0aW9uIHRvIFB5dGhvbiBwcm9ncmFtbWluZyBjb3Vyc2UuCkdlbmVyYXRlIHRoZSBzdHVkZW50J3MgbmV4dCBhdHRlbXB0IGF0IHRoZSBUT0RPIENPREUgb2YgdGhlIGN1cnJlbnQgcHJvYmxlbSwgdXNpbmcgYm90aCB0aGVpciBwcmlvciBzdWJtaXNzaW9ucyBhbmQgdGhlIGZlZWRiYWNrIHRoZXkgcmVjZWl2ZWQuCgpZb3VyIHRhc2sgaGFzIHR3byBzdGVwcy4KCiMjIyBTVEVQIDE6IEdlbmVyYXRlIHRoZSBzdHVkZW50J3MgaW50ZXJuYWwgZGlhbG9ndWUgYmVmb3JlIHRoZWlyIG5leHQgc3VibWlzc2lvbiB1c2luZyA8dGhpbms+IGFuZCA8L3RoaW5rPiB0Y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vbnRlbnRzIG9mIHRoZSBUT0RPIENPREUuIERvIG5vdCBpbmNsdWRlIGRvY3N0cmluZ3Mgb3IgYW55dGhpbmcgb3V0c2lkZSBpdC4KLSBBcyBhIG5vdmljZSBzdHVkZW50LCB5b3VyIGF0dGVtcHRzIG1heSBpbmNsdWRlIG1pc3Rha2VzIG9yIHBhcnRpYWwgZml4ZXMuCi0gRklYRUQgQ09ERSBpcyBwcm92aWRlZCAtIGRvIG5vdCBjb3B5LCBtb2RpZnksIG9yIGluY2x1ZGUgaXQuCi0gVXNlIHByaW9yIGZlZWRiYWNrIHRvIGluZm9ybSB5b3VyIGNvZGUgcmV2aXNpb24uCi0gSWYgdGhlIGdlbmVyYXRlZCBhdHRlbXB0IGlzIHRoZSBzdHVkZW50J3MgZmluYWwgc3VibWlzc2lvbiwgYXBwZW5kICI8U1VCTUlUPiIgYXQgdGhlIGVuZC4KLSBVc2UgUHl0aG9uIHByb2dyYW1taW5nIGxhbmd1YWdl)YouaresimulatingastudenttakinganintroductiontoPythonprogrammingcourse\.Generatethestudent’snextattemptattheTODOCODEofthecurrentproblem,usingboththeirpriorsubmissionsandthefeedbacktheyreceived\.Yourtaskhastwosteps\.\#\#\#STEP1:Generatethestudent’sinternaldialoguebeforetheirnextsubmissionusing<think\>and</think\>tags\.<think\>Writethestudent’sinternaldialogueinfirst\-personvoice\.Thedialogueshouldreflectwhatthestudentlikelythoughtbeforeproducingthesubsequentsubmission\(i\.e\.,the"voiceintheirhead"\)\.Itshouldreadlikeabriefthink\-aloudexplanationoftheirreasoning\.Thethoughtshouldsoundlikeanoviceprogrammerthinkingthroughtheproblem:informal,tentative,andsometimesincomplete\.Itmayincludeuncertainty,guesses,orsmallmisunderstandings,andmayoccasionallyincludequestionsthestudentasksthemselves\.</think\>\#\#\#STEP2:Generatethestudent’snextcodesubmission\.\-Usetheinternaldialogueabovetoinformthecodethestudentwritesnext\.\-Whenwritingthecode,youmustwrapthegeneratedcodein<code\>and</code\>tags\.\-OnlywritethecontentsoftheTODOCODE\.Donotincludedocstringsoranythingoutsideit\.\-Asanovicestudent,yourattemptsmayincludemistakesorpartialfixes\.\-FIXEDCODEisprovided\-donotcopy,modify,orincludeit\.\-Usepriorfeedbacktoinformyourcoderevision\.\-Ifthegeneratedattemptisthestudent’sfinalsubmission,append"<SUBMIT\>"attheend\.\-UsePythonprogramminglanguage

User Prompt[⬇](data:text/plain;base64,UFJPQkxFTSBJTlNUUlVDVElPTlM6CntpbnN0cnVjdGlvbnN9CgpGSVhFRCBDT0RFOgo8Y29kZT57Zml4ZWRfY29kZX08L2NvZGU+CgpUT0RPIENPREU6Cjxjb2RlPntza2VsZXRvbl9jb2RlfTwvY29kZT4KClNVQk1JU1NJT04gSElTVE9SWSAoQ09ERSArIEZFRURCQUNLKToKe3N1Ym1pc3Npb25zX3dpdGhfZmVlZGJhY2t9)PROBLEMINSTRUCTIONS:\{instructions\}FIXEDCODE:<code\>\{fixed\_code\}</code\>TODOCODE:<code\>\{skeleton\_code\}</code\>SUBMISSIONHISTORY\(CODE\+FEEDBACK\):\{submissions\_with\_feedback\}

Figure 8:Prompt template for CoT\-based prompting models\.The model is instructed to first generate an internal dialogue \(<think\>\.\.\.</think\>\) and then produce the next code submission \(<code\>\.\.\.</code\>\)\.System Prompt[⬇](data:text/plain;base64,WW91IGFyZSBzaW11bGF0aW5nIGEgc3R1ZGVudCB0YWtpbmcgYW4gaW50cm9kdWN0aW9uIHRvIFB5dGhvbiBwcm9ncmFtbWluZyBjb3Vyc2UuCkdlbmVyYXRlIHRoZSBzdHVkZW50J3MgbmV4dCBhdHRlbXB0IGF0IHRoZSBUT0RPIENPREUgb2YgdGhlIGN1cnJlbnQgcHJvYmxlbSwgdXNpbmcgYm90aCB0aGVpciBwcmlvciBzdWJtaXNzaW9ucyBhbmQgdGhlIGZlZWRiYWNrIHRoZXkgcmVjZWl2ZWQuCgpZb3VyIHRhc2sgaGFzIHRocmVlIHN0ZXBzLgoKIyMgU1RFUCAxOiBJbmZlci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lbnQsIHlvdXIgYXR0ZW1wdHMgbWF5IGluY2x1ZGUgbWlzdGFrZXMgb3IgcGFydGlhbCBmaXhlcy4KLSBGSVhFRCBDT0RFIGlzIHByb3ZpZGVkIC0gZG8gbm90IGNvcHksIG1vZGlmeSwgb3IgaW5jbHVkZSBpdC4KLSBVc2UgcHJpb3IgZmVlZGJhY2sgdG8gaW5mb3JtIHlvdXIgY29kZSByZXZpc2lvbi4KLSBJZiB0aGUgZ2VuZXJhdGVkIGF0dGVtcHQgaXMgdGhlIHN0dWRlbnQncyBmaW5hbCBzdWJtaXNzaW9uLCBhcHBlbmQgIjxTVUJNSVQ+IiBhdCB0aGUgZW5kLgotIFVzZSBQeXRob24gcHJvZ3JhbW1pbmcgbGFuZ3VhZ2U=)YouaresimulatingastudenttakinganintroductiontoPythonprogrammingcourse\.Generatethestudent’snextattemptattheTODOCODEofthecurrentproblem,usingboththeirpriorsubmissionsandthefeedbacktheyreceived\.Yourtaskhasthreesteps\.\#\#STEP1:Inferthestudent’sinternalstaterightafterreceivingthemostrecentfeedback\.Writethesefieldsfromathird\-personanalystperspectivedescribingthestudent,notinthestudent’sownvoice\.Thestatescorrespondtothreelearningdimensionscommonlyusedineducationaltheory:cognitive\(knowledgeandreasoning\),affective\(emotionsandattitudestowardlearning\),andaction\(theconcreteproblem\-solvingstepthestudentisabouttotake\)\.Useexactlythesetags:<cognitive\>Inonesentence,describethestudent’scurrentunderstandingoftheproblemorfeedback\.Thismayincluderecallingrelevantconcepts,interpretingthefeedback,applyingarule,analyzingthecauseofabug,orformingahypothesisabouthowtofixthecode\.Includebothcorrectandincorrectbeliefsormisconceptionssuggestedbythecodechanges\.</cognitive\><affective\>Inonesentence,describethestudent’semotionalormotivationalstatetowardthetask,suchasconfusion,uncertainty,frustration,confidence,curiosity,orpersistence\.Thisreflectshowthestudentisreactingtothefeedbackandthedifficultyoftheproblem\.</affective\><action\>Inonesentence,describetheconcreteprogrammingstepthestudentisabouttotakenext\.Thisshouldreflectthestudent’sproblem\-solvingaction\.</action\>\#\#STEP2:Generatethestudent’sinternaldialoguebeforetheirnextsubmissionusing<think\>and</think\>tags\.<think\>Writethestudent’sinternaldialogueinfirst\-personvoice,basedontheinferredstatesabove\(cognitive,affective,action\)\.Thedialogueshouldreflectwhatthestudentlikelythoughtbeforeproducingthesubsequentsubmission\(i\.e\.,the"voiceintheirhead"\)\.Itshouldreadlikeabriefthink\-aloudexplanationoftheirreasoning\.Thethoughtshouldsoundlikeanoviceprogrammerthinkingthroughtheproblem:informal,tentative,andsometimesincomplete\.Itmayincludeuncertainty,guesses,orsmallmisunderstandings,andmayoccasionallyincludequestionsthestudentasksthemselves\.</think\>\#\#STEP3:Generatethestudent’snextcodesubmission\.\-Usetheinternaldialogueabovetoinformthecodethestudentwritesnext\.\-Whenwritingthecode,youmustwrapthegeneratedcodein<code\>and</code\>tags\.\-OnlywritethecontentsoftheTODOCODE\.Donotincludedocstringsoranythingoutsideit\.\-Asanovicestudent,yourattemptsmayincludemistakesorpartialfixes\.\-FIXEDCODEisprovided\-donotcopy,modify,orincludeit\.\-Usepriorfeedbacktoinformyourcoderevision\.\-Ifthegeneratedattemptisthestudent’sfinalsubmission,append"<SUBMIT\>"attheend\.\-UsePythonprogramminglanguage

User Prompt[⬇](data:text/plain;base64,UFJPQkxFTSBJTlNUUlVDVElPTlM6CntpbnN0cnVjdGlvbnN9CgpGSVhFRCBDT0RFOgo8Y29kZT57Zml4ZWRfY29kZX08L2NvZGU+CgpUT0RPIENPREU6Cjxjb2RlPntza2VsZXRvbl9jb2RlfTwvY29kZT4KClNVQk1JU1NJT04gSElTVE9SWSAoQ09ERSArIEZFRURCQUNLKToKe3N1Ym1pc3Npb25zX3dpdGhfZmVlZGJhY2t9)PROBLEMINSTRUCTIONS:\{instructions\}FIXEDCODE:<code\>\{fixed\_code\}</code\>TODOCODE:<code\>\{skeleton\_code\}</code\>SUBMISSIONHISTORY\(CODE\+FEEDBACK\):\{submissions\_with\_feedback\}

Figure 9:Bloom’s Taxonomy\-inspired prompt template for structured CoT prompting\.The model first infers the student’s internal state across cognitive, affective, and action dimensions, then generates an internal dialogue \(<think\>\.\.\.</think\>\), followed by the next code submission \(<code\>\.\.\.</code\>\)\.
## Appendix GLLM Judge Evaluation Prompt

We provide the full prompt used for LLM\-based evaluation of the model\-generated internal dialogue alignment in[Figure 10](https://arxiv.org/html/2608.10492#A7.F10)\. The prompt instructs the judge \(GPT\-5\-mini\) to decompose the generated reasoning into atomic claims and assess whether each claim is supported by the real student’s code edits\.

System Prompt[⬇](data:text/plain;base64,WW91IGFyZSBldmFsdWF0aW5nIGEgbW9kZWwgdGhhdCBzaW11bGF0ZXMgYSBub3ZpY2Ugc3R1ZGVudCB3b3JraW5nIG9uIGEgUHl0aG9uIHByb2dyYW1taW5nIGFzc2lnbm1lbnQuCkV4dHJhY3QgZWFjaCBkaXN0aW5jdCBjbGFpbSBvciBpbnRlbnRpb24gZnJvbSB0aGUgU3ludGhldGljIFRoaW5rIChlLmcuLCAiSSB3aWxsIGFkZCBhIGJhc2UgY2FzZSIsICJJJ2xsIHVzZSBuICUgMTAiKS4gRm9yIGVhY2ggY2xhaW0sIGV2YWx1YXRlIGl0IGFnYWluc3QgYm90aCBkaWZmczoKLSAqKlRhc2sgMSoqIC0gRG9lcyB0aGUgY2xhaW0gYXBwZWFyIGluIHRoZSAqKnN5bnRoZXRpYyBjb2RlIGRpZmYqKiAodC0xIC0+IHN5bnRoZXRpYyB0KT8KLSAqKlRhc2sgMioqIC0gRG9lcyB0aGUgc2FtZSBjbGFpbSBhcHBlYXIgaW4gdGhlICoqR1QgY29kZSBkaWZmKiogKHQtMSAtPiBHVCB0KT8KSWYgYSBjbGFpbSBpcyByZWZsZWN0ZWQgaW4gYm90aCwgaXQgc3VnZ2VzdHMgdGhlIHN5bnRoZXRpYyB0aGluayBjYXB0dXJlcyB0aGUgc2FtZSBpbnRlbnQgYXMgdGhlIGdyb3VuZCB0cnV0aC4KCiMjIE91dHB1dCBGb3JtYXQKUmVzcG9uZCBpbiB0aGlzIGV4YWN0IEpTT04gZm9ybWF0Ogp7CiAgImNsYWltcyI6IFsKICAgIHsKICAgICAgImNsYWltIjogIjxjbGFpbSBleHRyYWN0ZWQgZnJvbSBzeW50aGV0aWMgdGhpbms+IiwKICAgICAgInRhc2sxX3JhdGlvbmFsZSI6ICI8d2h5IHRoaXMgY2xhaW0gaXMvaXNuJ3QgcmVmbGVjdGVkIGluIHRoZSBzeW50aGV0aWMgZGlmZj4iLAogICAgICAidGFzazFfcmVmbGVjdGVkIjogdHJ1ZSBvciBmYWxzZSwKICAgICAgInRhc2syX3JhdGlvbmFsZSI6ICI8d2h5IHRoaXMgY2xhaW0gaXMvaXNuJ3QgcmVmbGVjdGVkIGluIHRoZSBHVCBkaWZmPiIsCiAgICAgICJ0YXNrMl9yZWZsZWN0ZWQiOiB0cnVlIG9yIGZhbHNlCiAgICB9LAogICAgewogICAgICAiY2xhaW0iOiAiPGNsYWltIGV4dHJhY3RlZCBmcm9tIHN5bnRoZXRpYyB0aGluaz4iLAogICAgICAidGFzazFfcmF0aW9uYWxlIjogIjx3aHkgdGhpcyBjbGFpbSBpcy9pc24ndCByZWZsZWN0ZWQgaW4gdGhlIHN5bnRoZXRpYyBkaWZmPiIsCiAgICAgICJ0YXNrMV9yZWZsZWN0ZWQiOiB0cnVlIG9yIGZhbHNlLAogICAgICAidGFzazJfcmF0aW9uYWxlIjogIjx3aHkgdGhpcyBjbGFpbSBpcy9pc24ndCByZWZsZWN0ZWQgaW4gdGhlIEdUIGRpZmY+IiwKICAgICAgInRhc2syX3JlZmxlY3RlZCI6IHRydWUgb3IgZmFsc2UKICAgIH0KICBdCn0=)YouareevaluatingamodelthatsimulatesanovicestudentworkingonaPythonprogrammingassignment\.ExtracteachdistinctclaimorintentionfromtheSyntheticThink\(e\.g\.,"Iwilladdabasecase","I’llusen%10"\)\.Foreachclaim,evaluateitagainstbothdiffs:\-\*\*Task1\*\*\-Doestheclaimappearinthe\*\*syntheticcodediff\*\*\(t\-1\-\>synthetict\)?\-\*\*Task2\*\*\-Doesthesameclaimappearinthe\*\*GTcodediff\*\*\(t\-1\-\>GTt\)?Ifaclaimisreflectedinboth,itsuggeststhesyntheticthinkcapturesthesameintentasthegroundtruth\.\#\#OutputFormatRespondinthisexactJSONformat:\{"claims":\[\{"claim":"<claimextractedfromsyntheticthink\>","task1\_rationale":"<whythisclaimis/isn’treflectedinthesyntheticdiff\>","task1\_reflected":trueorfalse,"task2\_rationale":"<whythisclaimis/isn’treflectedintheGTdiff\>","task2\_reflected":trueorfalse\},\{"claim":"<claimextractedfromsyntheticthink\>","task1\_rationale":"<whythisclaimis/isn’treflectedinthesyntheticdiff\>","task1\_reflected":trueorfalse,"task2\_rationale":"<whythisclaimis/isn’treflectedintheGTdiff\>","task2\_reflected":trueorfalse\}\]\}

User Prompt[⬇](data:text/plain;base64,IyMjIFByb2JsZW0gRGVzY3JpcHRpb246CntpbnN0cnVjdGlvbnN9CgojIyMgU3R1ZGVudCdzIENvZGUgYXQgVGltZSB0LTEgKG1vc3QgcmVjZW50IHByaW9yIHN1Ym1pc3Npb24pOgp7Y29kZV90bTF9CgojIyMgRmVlZGJhY2sgdGhlIFN0dWRlbnQgUmVjZWl2ZWQgYXQgVGltZSB0LTE6CntmZWVkYmFja190bTF9CgojIyMgR3JvdW5kIFRydXRoIENvZGUgYXQgVGltZSB0ICh3aGF0IHRoZSByZWFsIHN0dWRlbnQgc3VibWl0dGVkIG5leHQpOgp7Z3RfY29kZV90fQoKIyMjIFN5bnRoZXRpYyBUaGluayBhdCBUaW1lIHQtMSAod2hhdCB0aGUgbW9kZWwgdGhpbmtzIHRoZSBzdHVkZW50IHRob3VnaHQpOgp7c3luX3RoaW5rX3RtMX0KCiMjIyBTeW50aGV0aWMgQ29kZSBhdCBUaW1lIHQgKHdoYXQgdGhlIG1vZGVsIHByZWRpY3RzIHRoZSBzdHVkZW50IHdpbGwgc3VibWl0IG5leHQpOgp7c3luX2NvZGVfdH0KCiMjIyBDb2RlIERpZmYgKHQtMSAtPiBzeW50aGV0aWMgdCk6CntzeW5fZGlmZn0KCiMjIyBDb2RlIERpZmYgKHQtMSAtPiBHVCB0KToKe2d0X2RpZmZ9)\#\#\#ProblemDescription:\{instructions\}\#\#\#Student’sCodeatTimet\-1\(mostrecentpriorsubmission\):\{code\_tm1\}\#\#\#FeedbacktheStudentReceivedatTimet\-1:\{feedback\_tm1\}\#\#\#GroundTruthCodeatTimet\(whattherealstudentsubmittednext\):\{gt\_code\_t\}\#\#\#SyntheticThinkatTimet\-1\(whatthemodelthinksthestudentthought\):\{syn\_think\_tm1\}\#\#\#SyntheticCodeatTimet\(whatthemodelpredictsthestudentwillsubmitnext\):\{syn\_code\_t\}\#\#\#CodeDiff\(t\-1\-\>synthetict\):\{syn\_diff\}\#\#\#CodeDiff\(t\-1\-\>GTt\):\{gt\_diff\}

Figure 10:Prompt used for claim\-level evaluation of the internal dialogue\. A single call produces both judgments:task2\_reflectedagainst the ground\-truth diff gives the alignment score reported in[Section 4\.2](https://arxiv.org/html/2608.10492#S4.SS2), andtask1\_reflectedagainst the model\-generated diff gives the self\-consistency score reported in[Appendix C](https://arxiv.org/html/2608.10492#A3)\.

## Appendix HQualitative Examples

### H\.1INSIDEvs\. Prompting Model

We provide qualitative examples comparing generated internal dialogue and code against real student behavior in[Figure 11](https://arxiv.org/html/2608.10492#A8.F11)\. These examples illustrate how INSIDE captures reasoning that aligns with observed code edits, in contrast to prompting\-based methods\.

Real student codett\-1:[⬇](data:text/plain;base64,ZGVmIG1ha2VfcmVwZWF0ZXIoZiwgbik6CiAgICBkZWYgZnVuYyh4KToKICAgICAgICBmb3IgXyBpbiByYW5nZShuKToKICAgICAgICAgICAgZiA9IGYoZikKICAgICAgICByZXR1cm4gZgogICAgcmV0dXJuIGZ1bmNAXGNvbG9yYm94e3JlZCEzMH17KCl9QAogICAgIyBuZXcgPSBmCiAgICAjIGZvciBfIGluIHJhbmdlKG4pOgogICAgIyAgICAgbmV3ID0gZihuZXcpCiAgICAjIHJldHVybiBuZXcoKQ==)defmake\_repeater\(f,n\):deffunc\(x\):for\_inrange\(n\):f=f\(f\)returnfreturnfunc\(\)\#new=f\#for\_inrange\(n\):\#new=f\(new\)\#returnnew\(\)Feedbacktt\-1: You’re on the right track with the helper function, but there’s a small mistake\. In the loop, you’re trying to reassign ‘f’ to ‘f\(f\)’, but ‘f’ is a function and you should be applying ‘f’ to an argument, not to the function ‘f’ itself\. Also, you’re trying to call ‘func\(\)’ at the end, but ‘func’ should be returned as a function, not called\. Try to apply ‘f’ to ‘x’ in the loop and return ‘func’ instead of ‘func\(\)’\.Qwen3\-8B\-BloomCoT Internal dialogue \(Alignment: 50%\): Okay, I need to make a function that applies ‘f’ ‘n’ times\. I think I should create a helper function inside ‘make\_repeater’ that takes ‘x’ and applies ‘f’ repeatedly\. Let me try to loop ‘n’ times and apply ‘f’ to the result each time\. Oh right, I should start with ‘x’ and then apply ‘f’ to it in each iteration\. Let me make sure I’m not calling ‘f’ incorrectly\.Qwen3\-8B\-INSIDE Internal dialogue \(Alignment: 100%\): Okay, they said I should apply f to an argument, so maybe I can do f = f\(f\(x\)\) inside the loop and then return f at the end\. I’ll keep the helper and return it\-\-\-hopefully this counts as applying f n times\.Real student codett:[⬇](data:text/plain;base64,ZGVmIG1ha2VfcmVwZWF0ZXIoZiwgbik6CiAgICBkZWYgZnVuYyh4KToKICAgICAgICBmb3IgXyBpbiByYW5nZShuKToKICAgICAgICAgICAgZiA9IGYoZkBcY29sb3Jib3h7Z3JlZW4hMzB9eyh4KX1AKQogICAgICAgIHJldHVybiBmCiAgICByZXR1cm4gZnVuYwogICAgIyBuZXcgPSBmCiAgICAjIGZvciBfIGluIHJhbmdlKG4pOgogICAgIyAgICAgbmV3ID0gZihuZXcpCiAgICAjIHJldHVybiBuZXcoKQ==)defmake\_repeater\(f,n\):deffunc\(x\):for\_inrange\(n\):f=f\(f\(x\)\)returnfreturnfunc\#new=f\#for\_inrange\(n\):\#new=f\(new\)\#returnnew\(\)

Figure 11:A qualitative comparison of synthetic internal dialogue generated by Qwen3\-8B\-BloomCoT and Qwen3\-8B\-INSIDE for the same student code and feedback\(red highlightsindicate code removed from the previous student submission, whilegreen highlightsindicate code added in the next student submission\)\. BloomCoT generates a clean, competent think trace reasoning toward the correct solution, yet the resulting student code remains buggy and misaligned with that reasoning\. INSIDE generates a messier, uncertain think trace that mirrors how a novice might partially misinterpret the feedback — producingf = f\(f\(x\)\)as a guess — which faithfully matches the actual student code change\. This example illustrates that INSIDE captures the kind of confused, partially\-correct reasoning real students exhibit, rather than generating idealized reasoning decoupled from the student’s actual behavior\.
### H\.2Failure Mode Analysis

We conducted a qualitative error analysis ofINSIDE’s failure cases\. From the generated traces of theINSIDEmodels, we randomly sampled 25 examples from the bottom quartile of alignment scores and inspected the student’s codect−1,si,puc\_\{t\-1,s\_\{i\},p\_\{u\}\}, the feedbackft−1,si,puf\_\{t\-1,s\_\{i\},p\_\{u\}\}, the generated internal dialoguez^t,si,pu\\hat\{z\}\_\{t,s\_\{i\},p\_\{u\}\}, and the student’s next submissionct,si,puc\_\{t,s\_\{i\},p\_\{u\}\}\. We grouped the observations into three recurring failure categories:no student edit\(48%\), where the student resubmitted the same code despite the feedback;overestimating feedback uptake\(44%\), where the generated dialogue described a more feedback\-responsive repair than the student implemented; andunderestimating feedback uptake\(8%\), where the dialogue failed to anticipate a partial improvement the student made\. Representative examples are shown in[Figure 12](https://arxiv.org/html/2608.10492#A8.F12),[Figure 13](https://arxiv.org/html/2608.10492#A8.F13), and[Figure 14](https://arxiv.org/html/2608.10492#A8.F14)\.

Real student codett\-1:[⬇](data:text/plain;base64,ZGVmIG51bV9laWdodHMobik6)defnum\_eights\(n\):Feedbacktt\-1: It seems like you haven’t written any code for the num\_eights function yet\. Remember, you need to use recursion to solve this problem\. Think about how you can break down the problem: you can check if the last digit of the number is 8, and then recursively call the function on the rest of the number\. How can you get the last digit and the rest of the number?Qwen3\-8B\-INSIDE Internal dialogue: Okay, I can check the last digit with n % 10 and if it’s 8 add 1, then call the function on n // 10\. I’ll write a base case for n == 0 and just return 0 there\-\-\-this should work without loops or assignments\.Real student codett:[⬇](data:text/plain;base64,ZGVmIG51bV9laWdodHMobik6)defnum\_eights\(n\):

Figure 12:Representative example for “No student edit\.”Despite receiving detailed feedback outlining a recursive approach, the real student resubmits an empty function stub unchanged\. The INSIDE\-generated internal dialogue, in contrast, reflects a plausible and largely correct plan for solving the problem \(usingn % 10andn // 10with a base case\), illustrating a case where the model’s inferred reasoning is more feedback\-responsive than the student’s actual \(lack of\) action\.Real student codett\-1:[⬇](data:text/plain;base64,ZGVmIG51bV9laWdodHMobik6CiAgICBpZiBuIC8vIDEwID09IDAgYW5kIG4gJSAxMCA9PSA4OgogICAgICAgIHJldHVybiAxCiAgICBlbGlmIG4gLy8gMTAgPT0gMCBhbmQgbiAlIDEwICE9IDg6CiAgICAgICAgcmV0dXJuIDAKICAgIGVsc2U6CiAgICAgICAgcmV0dXJuIG51bV9laWdodHMobiAvLyAxMCkgQFxjb2xvcmJveHtyZWQhMzB9eysgMX1A)defnum\_eights\(n\):ifn//10==0andn%10==8:return1elifn//10==0andn%10\!=8:return0else:returnnum\_eights\(n//10\)\+ 1Feedbacktt\-1: You’re almost there\! However, you’re currently adding 1 to the count of 8’s in every recursive call, not just when the last digit is 8\. You should only add 1 if the last digit is 8\. Try to fix this issue and run your code again\.Qwen3\-8B\-INSIDE Internal dialogue: Oh, I was adding 1 every time\-\-\-so I should only add 1 when the last digit is 8\. I’ll keep my base cases and just return 1 \+ num\_eights\(n // 10\) when n % 10 == 8, otherwise just recurse on n // 10\.Real student codett:[⬇](data:text/plain;base64,ZGVmIG51bV9laWdodHMobik6CiAgICBpZiBuIC8vIDEwID09IDAgYW5kIG4gJSAxMCA9PSA4OgogICAgICAgIHJldHVybiAxCiAgICBlbGlmIG4gLy8gMTAgPT0gMCBhbmQgbiAlIDEwICE9IDg6CiAgICAgICAgcmV0dXJuIDAKICAgIGVsc2U6CiAgICAgICAgcmV0dXJuQFxjb2xvcmJveHtncmVlbiEzMH17KDEgKyB9QG51bV9laWdodHMobiAvLyAxMClAXGNvbG9yYm94e2dyZWVuITMwfXspfUA=)defnum\_eights\(n\):ifn//10==0andn%10==8:return1elifn//10==0andn%10\!=8:return0else:return\(1 \+num\_eights\(n//10\)\)

Figure 13:Representative example for “Overestimating feedback uptake”\(red highlightsindicate code removed from the previous student submission, whilegreen highlightsindicate code added in the next student submission\)\. The generated internal dialogue anticipates a targeted fix conditioning the increment onn % 10 == 8, but the real student’s actual edit only reorders the existing expression, moving\+ 1in front of the recursive call and wrapping it in parentheses\.Real student codett\-1:[⬇](data:text/plain;base64,ZGVmIG1ha2VfcmVwZWF0ZXIoZiwgbik6CiAgICBrID0gMAogICAgeCA9ICgpCiAgICB3aGlsZSBrIDwgbjoKICAgICAgICBAXGNvbG9yYm94e3JlZCEzMH17eH1AID0gZih4KQogICAgICAgIGsgKz0gMQogICAgcmV0dXJuIGYoeCk=)defmake\_repeater\(f,n\):k=0x=\(\)whilek<n:x=f\(x\)k\+=1returnf\(x\)Feedbacktt\-1: You’re still returning a value, not a function\. Remember, make\_repeater should return a function that, when called with an argument x, applies f to x n times\. This returned function should take one argument\. Also, you’re still trying to use x before it’s defined\. You should define x inside the function you’re returning, not in make\_repeater\.Qwen2\.5\-Coder\-7B\-INSIDE Internal dialogue: They keep saying return a function, but maybe if I just loop n times and update x with f\(x\), then return x, that shows it applied f multiple times\. I’m not sure how to make the returned function take x, but at least this uses f in a loop and returns something\.Real student codett:[⬇](data:text/plain;base64,ZGVmIG1ha2VfcmVwZWF0ZXIoZiwgbik6CiAgICBrID0gMAogICAgd2hpbGUgayA8IG46CiAgICAgICAgQFxjb2xvcmJveHtncmVlbiEzMH17Zn1AID0gZih4KQogICAgICAgIGsgKz0gMQogICAgcmV0dXJuIEBcY29sb3Jib3h7Z3JlZW4hMzB9e2xhbWJkYSB4OiBmKHgpfUA=)defmake\_repeater\(f,n\):k=0whilek<n:f=f\(x\)k\+=1returnlambda x: f\(x\)

Figure 14:Representative example for “Underestimating feedback uptake”\(red highlightsindicate code removed from the previous student submission, whilegreen highlightsindicate code added in the next student submission\)\. The generated internal dialogue anticipates only an incremental fix within the existing loop\-based structure, but the real student makes a more substantial revision by introducing alambdato return a function, a change the dialogue fails to anticipate\.

Similar Articles

Simulate, Reason, Decide: Scientific Reasoning with LLMs for Simulation-Driven Decision Making

arXiv cs.AI

Researchers from the University of Michigan introduce MechSim, a mechanism-grounded neuro-symbolic reasoning framework that enables LLM agents to reason about the internal assumptions, dependencies, and execution behavior of scientific simulators rather than treating them as black boxes. The framework improves explanation quality and decision-making reliability across high-stakes domains like healthcare, finance, and public policy.