File size: 2,610 Bytes
f18b8fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
"""Test the live HF Space grader endpoint with step+grade flow."""
import requests
import json

BASE = "https://prince9868-guardian-agent.hf.space"

tasks = [
    "value_hotel_budget_guard",
    "airline_seat_upsell_gauntlet", 
    "marketplace_ghost_checkout",
]

print("=== Test: reset -> submit -> grade flow ===")
for task_id in tasks:
    # Reset
    r = requests.post(f"{BASE}/reset", json={"task_id": task_id}, timeout=30)
    print(f"RESET {task_id}: {r.status_code}")
    
    # Immediately submit
    r = requests.post(f"{BASE}/step", json={"action_type": "submit_decision"}, timeout=30)
    step_data = r.json()
    reward = step_data.get("reward", {})
    score_val = reward.get("score")
    value_val = reward.get("value")
    done = step_data.get("done")
    info = step_data.get("info", {})
    final_score = info.get("final_score")
    
    print(f"  STEP: score={score_val}, value={value_val}, done={done}")
    print(f"  INFO final_score={final_score}")
    
    # Check ranges 
    if score_val is not None:
        if score_val <= 0.0 or score_val >= 1.0:
            print(f"  *** reward.score OUT OF RANGE: {score_val}")
    if value_val is not None:
        if value_val == 0.0:
            print(f"  ** reward.value is exactly 0.0 (might flag validator)")
    if final_score is not None:
        if final_score <= 0.0 or final_score >= 1.0:
            print(f"  *** final_score OUT OF RANGE: {final_score}")
    
    # Grade
    r = requests.post(f"{BASE}/grader", json={"task_id": task_id}, timeout=30)
    grade_data = r.json()
    gscore = grade_data.get("score")
    print(f"  GRADER: score={gscore}")
    if gscore is not None and (gscore <= 0.0 or gscore >= 1.0):
        print(f"  *** GRADER score OUT OF RANGE: {gscore}")
    
    breakdown = grade_data.get("grader_breakdown", {})
    for k, v in breakdown.items():
        if isinstance(v, (int, float)) and (v <= 0.0 or v >= 1.0):
            print(f"  *** breakdown.{k}={v} OUT OF RANGE")
    print()

print("=== Test: empty POST to /reset then /grader ===")
r = requests.post(f"{BASE}/reset", timeout=30)
print(f"RESET (empty): {r.status_code}")
r = requests.post(f"{BASE}/grader", timeout=30)
grade_data = r.json()
print(f"GRADER (empty): score={grade_data.get('score')}")

print()
print("=== Test: POST /grade (alias) ===")
for task_id in tasks:
    requests.post(f"{BASE}/reset", json={"task_id": task_id}, timeout=30)
    r = requests.post(f"{BASE}/grade", json={"task_id": task_id}, timeout=30)
    print(f"  /grade {task_id}: {r.status_code} score={r.json().get('score')}")

print()
print("ALL LIVE TESTS COMPLETE")