File size: 3,946 Bytes
0c470ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
"""

Debug script to trace why final_score is 0.

"""

import asyncio
from client import AdaptiveProjectManagerClient
from models import ProjectAction, Assignment

async def debug_scoring():
    """Debug the scoring issue step by step."""
    
    print("=" * 80)
    print("DEBUG: Final Score Investigation")
    print("=" * 80)
    
    env = await AdaptiveProjectManagerClient.from_docker_image("adaptive-project-manager:latest")
    
    try:
        result = await env.reset(task_id="easy")
        obs = result.observation
        
        print(f"\nInitial state:")
        print(f"  done: {result.done}")
        print(f"  metadata: {obs.metadata}")
        
        # Run just a few steps to complete quickly
        for i in range(15):
            if result.done:
                print(f"\n{'='*80}")
                print(f"EPISODE DONE at step {i}")
                print(f"{'='*80}")
                break
            
            # Simple strategy
            assignments = []
            available_tasks = [t for t in obs.tasks if t.status in ["todo", "in_progress"] and not t.dependencies]
            available_employees = [e for e in obs.employees if e.available]
            
            # Just assign first available employee to first available task
            for emp in available_employees[:2]:
                for task in available_tasks[:2]:
                    if task.required_skill in emp.skills:
                        assignments.append(Assignment(employee_id=emp.id, task_id=task.id))
                        available_tasks.remove(task)
                        break
            
            action = ProjectAction(assignments=assignments, contingency_action="none")
            result = await env.step(action)
            obs = result.observation
            
            completed = [t for t in obs.tasks if t.status == "done"]
            print(f"\nStep {i+1}: Day {obs.day}, done={result.done}, completed={len(completed)}/{len(obs.tasks)}")
            
            if result.done:
                print(f"\n{'='*80}")
                print(f"EPISODE DONE at step {i+1}")
                print(f"{'='*80}")
                print(f"  obs.done: {obs.done}")
                print(f"  result.done: {result.done}")
                print(f"  obs.metadata: {obs.metadata}")
                print(f"  obs.metadata type: {type(obs.metadata)}")
                
                final_score = obs.metadata.get("final_score", "NOT_FOUND")
                print(f"\n  Final score from metadata: {final_score}")
                
                # Check why it terminated
                print(f"\n  Termination reason:")
                print(f"    All tasks done: {all(t.status == 'done' for t in obs.tasks)}")
                print(f"    Deadline reached: {obs.day >= obs.day + obs.days_remaining}")
                print(f"    Budget exhausted: (can't check from client)")
                
                # Show task statuses
                print(f"\n  Task statuses:")
                for t in obs.tasks:
                    print(f"    {t.id}: {t.status}, critical={t.is_critical_path}")
                
                # Show final state
                print(f"\n  Final state:")
                print(f"    Day: {obs.day}")
                print(f"    Project completion: {obs.project_completion:.1%}")
                print(f"    Budget remaining: ${obs.budget_remaining:,.0f}")
                print(f"    Average burnout: {obs.average_burnout:.2f}")
                
                break
        
        if not result.done:
            print(f"\n⚠️  Episode did NOT complete in 15 steps")
        
        await env.close()
        
    except Exception as e:
        print(f"\nError: {e}")
        import traceback
        traceback.print_exc()

if __name__ == "__main__":
    asyncio.run(debug_scoring())