📄 Research Article
CODE-GEN: A Human-in-the-Loop RAG-Based Agentic AI System for Multiple-Choice Question Generation
A dual-agent RAG-based system for generating and validating coding comprehension MCQs, evaluated by 6 SMEs across 7 pedagogical dimensions (N=288 questions, 2,016 rating pairs). AI excels at criteria-matching and computational verification (concept alignment 98.6%, code validity 95.5%), but human expertise remains essential for distractor quality (79.9%) and pedagogically rich feedback — providing an evidence-based division of labor for Human In The Loop AI educational content generation.
Venue: AIED 2026 (short paper)
ArXiv: 2604.03926
Overview
CODE-GEN (Context-aligned, Output-validated, Dual-agent, Expert-guided GENeration) is a Human In The Loop AI Agentic AI system for generating contextually grounded multiple-choice coding comprehension questions. It integrates RAG with a dual-agent architecture separating question generation from quality validation.
Architecture
1. RAG Pipeline: Instructional materials (learning objectives, example questions, code) are parsed with a domain-specific chunking strategy that preserves semantic coherence, embedded via OpenAI text-embedding-3-small, and indexed in a FAISS vector store. On generation, nearest-neighbor retrieval injects relevant examples into the Generator's prompt.
2. Generator Agent (GPT-4.1): Produces MCQs with stem, executable code, four answer options, and explanatory feedback. Augmented with an Arithmetic Expression Evaluator tool for deterministic computation.
3. Validator Agent (GPT-5-mini): Independently assesses each question across seven pedagogical dimensions: question stem clarity, code validity, concept alignment, correct answer validity, distractor quality, correct answer feedback quality, and distractor feedback quality. Uses an Arithmetic Expression Evaluator and a Sandboxed Python Runner for code execution verification.
Evaluation
Key Results
| Dimension | Success Rate | Failure Rate |
|---|---|---|
| Concept Alignment | 98.6% | 0.3% |
| Question Stem Clarity | 97.9% | 2.1% |
| Code Validity | 95.5% | 3.1% |
| Correct Answer Feedback | 92.4% | 2.1% |
| Correct Answer Validity | 92.0% | 1.4% |
| Distractor Feedback Quality | 86.1% | 9.4% |
| Distractor Quality | 79.9% | 15.6% |
Division of Labor Findings
AI strengths (reliable automation):
Human-essential dimensions (require oversight):
Failure Patterns
Significance for Automated Assessment and Automated Question Generation
CODE-GEN demonstrates that agentic AI with RAG grounding and tool augmentation can serve as scalable first-line quality control for Automated Assessment item generation. The explicit evaluation of the Validator against human judgment — rather than assuming automated evaluation is reliable — provides an evidence-based framework for determining where AI can be safely delegated and where Human In The Loop AI oversight must be maintained.
Connected Concepts
Connected Articles
Citation
RAG-Based, C.A.H., Question, A.A.S.F.M., Frederick, X.D., Wang1, A.C., multiple-choice, A.A.I.W.A.G.A.P., 2,016, J.A.Q.T.S.P.A.T.O., & generation, H.A.A.E.I.A.E.C. (2026). CODE-GEN: A Human-in-the-Loop RAG-Based Agentic AI System for Multiple-Choice Question Generation