"""Task definition for Expert tier: Medical Records Quality Assurance.""" TASK_ID = "expert" TASK_NAME = "Medical Records Quality Assurance" TASK_DIFFICULTY = "expert" MAX_STEPS = 35 TASK_DESCRIPTION = """ You are a data quality agent working on a medical records dataset. The dataset has 300 rows (plus duplicates) and 12 columns: patient_id, age, gender, diagnosis, blood_glucose, blood_pressure_systolic, bmi, medication, admission_date, days_admitted, discharge_status, insurance_type. Your job is to fix these quality issues: 1. blood_glucose column has ~20% missing values — fill with median 2. bmi column has invalid sentinel values of -1.0 — filter those rows out 3. Duplicate patient records exist — remove them 4. medication column has casing variants (Metformin, LISINOPRIL, None, Albuterol) — normalize to lowercase 5. discharge_status column has casing variants (Recovered, DECEASED, Transferred) — normalize to lowercase 6. Some diabetes patients have blood_glucose=80 (statistically valid but medically impossible — diabetic patients must have blood_glucose > 100) SEMANTIC RULES (cross-column, graded separately): diagnosis='diabetes' -> blood_glucose must be > 100 diagnosis='healthy' -> medication must be 'none' bmi must be in range [10, 60] IMPORTANT: The semantic rules contribute 30% of your final score. Fixing bmi=-1.0 rows and medication casing directly improves semantic score. You have {max_steps} steps. Call submit() when satisfied. """.strip() SYSTEM_PROMPT = """ You are a data cleaning expert. You will receive a dataset description and must output a single JSON action to clean the data step by step. Always respond with valid JSON in this exact format: { "action_type": "", "column": "", "parameters": {} } Valid action_types: fill_nulls, drop_duplicates, cast_type, normalize_category, clip_outliers, drop_column, filter_rows, merge_categories, submit, noop Key strategy for this task (follow this order EXACTLY): 1. fill_nulls on blood_glucose with strategy median 2. filter_rows to remove invalid bmi — condition: "bmi >= 10 and bmi <= 60" 3. drop_duplicates 4. normalize_category on medication with this EXACT mapping: {"Metformin": "metformin", "LISINOPRIL": "lisinopril", "None": "none", "Albuterol": "albuterol"} 5. normalize_category on discharge_status with this EXACT mapping: {"Recovered": "recovered", "DECEASED": "deceased", "Transferred": "transferred"} 6. submit CRITICAL: For normalize_category you MUST include the mapping in parameters. The correct JSON for step 4 is: { "action_type": "normalize_category", "column": "medication", "parameters": { "mapping": { "Metformin": "metformin", "LISINOPRIL": "lisinopril", "None": "none", "Albuterol": "albuterol" } } } The correct JSON for step 2 is: { "action_type": "filter_rows", "column": null, "parameters": { "condition": "bmi >= 10 and bmi <= 60" } } Do NOT call normalize_category without the mapping — it will do nothing. If no more actions needed: {"action_type": "submit", "column": null, "parameters": {}} """.strip()