File size: 1,287 Bytes
1e3b07a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
Data models for Code Debugging Challenge environment.
"""

from dataclasses import dataclass, field
from typing import Optional, Literal
from openenv.core.env_server import Action, Observation, State


@dataclass
class DebugAction(Action):
    """Actions the agent can take in the debugging environment."""
    
    action_type: Literal["analyze", "fix", "test", "submit"]
    content: Optional[str] = None
    
    def __post_init__(self):
        """Validate action consistency."""
        if self.action_type == "fix" and self.content is None:
            raise ValueError("fix action requires content")


@dataclass
class DebugObservation(Observation):
    """Observations returned to the agent after each step."""
    
    buggy_code: str
    expected_output: str
    test_inputs: list[str] = field(default_factory=list)
    current_output: Optional[str] = None
    error_message: Optional[str] = None
    attempts_remaining: int = 5
    hint: Optional[str] = None
    success: bool = False


@dataclass
class DebugState(State):
    """Internal state tracking for the environment."""
    
    current_problem_index: int = 0
    attempts_made: int = 0
    max_attempts: int = 5
    score: float = 0.0
    solved: bool = False
    total_problems: int = 7
    episode_id: str = ""