Tarun-sar0ya commited on
Commit
b9bd5e9
·
verified ·
1 Parent(s): 7fa47a2

Update tasks/wrong_endpoint/grader.py

Browse files
Files changed (1) hide show
  1. tasks/wrong_endpoint/grader.py +26 -6
tasks/wrong_endpoint/grader.py CHANGED
@@ -1,9 +1,29 @@
1
- """Grader for wrong_endpoint task: 404 Not Found."""
 
2
 
3
- from tasks.grading_helper import run_agent_on_incident
 
4
 
 
 
 
 
 
5
 
6
- def grade() -> float:
7
- """Grade the wrong_endpoint task. Returns score between 0 and 1."""
8
- score = run_agent_on_incident("wrong_endpoint")
9
- return max(0.001, min(0.999, score))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def grade(trajectory) -> float:
2
+ """Grade the wrong_endpoint task based on agent trajectory.
3
 
4
+ Args:
5
+ trajectory: List of (action, observation, reward) tuples from the episode.
6
 
7
+ Returns:
8
+ Score between 0 and 1.
9
+ """
10
+ if not trajectory:
11
+ return 0.0
12
 
13
+ # Check if agent used change_endpoint to fix the 404 error
14
+ actions = [step[0] if isinstance(step, (list, tuple)) else step.get("action", "") for step in trajectory]
15
+
16
+ correct_action_used = "change_endpoint" in actions
17
+ resolved = any(
18
+ (step[2] > 0 if isinstance(step, (list, tuple)) else step.get("reward", 0) > 0)
19
+ for step in trajectory
20
+ )
21
+
22
+ if correct_action_used and resolved:
23
+ return 0.95
24
+ elif correct_action_used:
25
+ return 0.6
26
+ elif resolved:
27
+ return 0.4
28
+ else:
29
+ return 0.05