Spaces:
Sleeping
Sleeping
| """Grader for missing_fields task: 400 Bad Request - missing email field.""" | |
| import sys | |
| from pathlib import Path | |
| _project_root = str(Path(__file__).parent.parent.parent) | |
| if _project_root not in sys.path: | |
| sys.path.insert(0, _project_root) | |
| from environment.api_triage_env import APITriageEnv | |
| from environment.incident_generator import get_incident_by_type | |
| def grade() -> float: | |
| """Grade the missing_fields task by simulating an optimal agent. | |
| Returns: | |
| Score strictly between 0 and 1. | |
| """ | |
| try: | |
| env = APITriageEnv(max_steps=10) | |
| env.incident = get_incident_by_type("missing_fields") | |
| if env.incident is None: | |
| return 0.1 | |
| env.fix_applied = False | |
| env.done = False | |
| env.step_counter = 0 | |
| env.total_reward = 0.0 | |
| # Optimal sequence: inspect → correct fix → resolve | |
| actions = ["inspect_logs", "add_field", "resolve"] | |
| for action in actions: | |
| state, reward, done, info = env.step(action) | |
| if done: | |
| if info.get("resolution") == "success": | |
| return 0.95 | |
| else: | |
| return 0.1 | |
| return 0.1 | |
| except Exception: | |
| return 0.1 | |