Kavya988 commited on
Commit
2bdbddc
·
verified ·
1 Parent(s): efdfb62

Fix: update tasks/auth_error/grader.py

Browse files
Files changed (1) hide show
  1. tasks/auth_error/grader.py +13 -23
tasks/auth_error/grader.py CHANGED
@@ -1,23 +1,18 @@
1
  """Grader for auth_error task: 401 Unauthorized - expired API key."""
2
 
3
- import sys
4
- from pathlib import Path
5
-
6
- _project_root = str(Path(__file__).parent.parent.parent)
7
- if _project_root not in sys.path:
8
- sys.path.insert(0, _project_root)
9
-
10
- from environment.api_triage_env import APITriageEnv
11
- from environment.incident_generator import get_incident_by_type
12
-
13
 
14
  def grade() -> float:
15
- """Grade the auth_error task by simulating an optimal agent.
16
-
17
- Returns:
18
- Score strictly between 0 and 1.
19
- """
20
  try:
 
 
 
 
 
 
 
 
 
21
  env = APITriageEnv(max_steps=10)
22
  env.incident = get_incident_by_type("auth_error")
23
  if env.incident is None:
@@ -27,15 +22,10 @@ def grade() -> float:
27
  env.step_counter = 0
28
  env.total_reward = 0.0
29
 
30
- # Optimal sequence: inspect correct fix → resolve
31
- actions = ["inspect_logs", "refresh_token", "resolve"]
32
- for action in actions:
33
- state, reward, done, info = env.step(action)
34
  if done:
35
- if info.get("resolution") == "success":
36
- return 0.95
37
- else:
38
- return 0.1
39
  return 0.1
40
  except Exception:
41
  return 0.1
 
1
  """Grader for auth_error task: 401 Unauthorized - expired API key."""
2
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  def grade() -> float:
5
+ """Grade the auth_error task. Returns float strictly between 0 and 1."""
 
 
 
 
6
  try:
7
+ import sys
8
+ from pathlib import Path
9
+ _root = str(Path(__file__).resolve().parent.parent.parent)
10
+ if _root not in sys.path:
11
+ sys.path.insert(0, _root)
12
+
13
+ from environment.api_triage_env import APITriageEnv
14
+ from environment.incident_generator import get_incident_by_type
15
+
16
  env = APITriageEnv(max_steps=10)
17
  env.incident = get_incident_by_type("auth_error")
18
  if env.incident is None:
 
22
  env.step_counter = 0
23
  env.total_reward = 0.0
24
 
25
+ for action in ["inspect_logs", "refresh_token", "resolve"]:
26
+ _, _, done, info = env.step(action)
 
 
27
  if done:
28
+ return 0.95 if info.get("resolution") == "success" else 0.1
 
 
 
29
  return 0.1
30
  except Exception:
31
  return 0.1