from services.data_loader import load_questions, load_personas
from services.simulator import SimulationEngine
import config

def debug_memory():
    print("🧠 Debugging Memory State...")
    questions_map = load_questions()
    grit_qs = questions_map.get('Grit', [])
    q1 = grit_qs[0]
    print(f"--- Q1 BEFORE PERSONA ---")
    print(f"Code: {q1['q_code']}")
    print(f"Options: {q1['options_list']}")
    
    adolescents, _ = load_personas()
    student = adolescents[0]
    
    engine = SimulationEngine(config.ANTHROPIC_API_KEY)
    # This call shouldn't mutate Q1
    _ = engine.construct_system_prompt(student)
    _ = engine.construct_user_prompt([q1])
    
    print(f"\n--- Q1 AFTER PROMPT CONSTRUCTION ---")
    print(f"Code: {q1['q_code']}")
    print(f"Options: {q1['options_list']}")

if __name__ == "__main__":
    debug_memory()
