""" tasks/task_hard.py -- Hard task: 4 variables, high noise, random domain. The agent must discover a complex causal graph with high noise and a tight budget. This is designed to challenge frontier models. Grader returns 0.0-1.0 based on: - Hypothesis accuracy (40%) - Precision bonus (15%) - Efficiency bonus (15%) - Calibration (15%) - Avoiding contradiction penalty (15%) """ from __future__ import annotations from typing import Any TASK_HARD = { "id": "hard", "name": "Hard -- Complex Graph Under Noise", "description": ( "Discover causal relationships among four variables under " "high noise (sigma=0.50) with a tight budget (8 steps). " "Requires strategic experiment design and careful reasoning." ), "difficulty": "hard", "reset_kwargs": { "noise_level": "high", "seed": 999, }, } def grade_hard(episode_result: dict[str, Any]) -> float: """ Grade a hard-task episode. Returns a score in [0.0, 1.0]. """ accuracy = episode_result.get("accuracy_score", 0.0) precision = episode_result.get("precision_bonus", 0.0) efficiency = episode_result.get("efficiency_bonus", 0.0) calibration = episode_result.get("calibration_score", 0.0) contradiction = episode_result.get("contradiction_penalty", 0.0) no_contradiction = 1.0 if contradiction >= 0.0 else 0.0 raw = ( 0.40 * min(accuracy, 1.0) + 0.15 * min(precision / 0.10, 1.0) + 0.15 * min(efficiency / 0.15, 1.0) + 0.15 * min(calibration / 0.20, 1.0) + 0.15 * no_contradiction ) return round(max(0.0, min(1.0, raw)), 4)