File size: 1,524 Bytes
761f203
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from __future__ import annotations

from typing import Any, Literal

from pydantic import BaseModel, Field

try:
    from openenv.core.env_server.types import Action, Observation
except Exception:  # pragma: no cover
    Action = BaseModel  # type: ignore[misc,assignment]
    Observation = BaseModel  # type: ignore[misc,assignment]

TaskType = Literal["classify", "root_cause", "fix_proposal"]


class FlakySleuthObservation(Observation):
    repo_url: str = Field(..., description="Repository URL or fixture reference")
    test_name: str = Field(..., description="Pytest test identifier")
    test_code: str = Field(..., description="Test source snippet")
    file_tree: list[str] = Field(default_factory=list, description="Top-level file tree")
    tool_output: str | None = Field(default=None, description="Result of the previous exploratory action")
    task_type: TaskType = Field(..., description="Current task type")
    task_description: str = Field(..., description="Instruction for the agent")
    step_count: int = Field(default=0, description="Current episode step count")


class FlakySleuthAction(Action):
    action_type: Literal[
        "read_file",
        "search_code",
        "run_test",
        "classify_flakiness",
        "classify_root_cause",
        "propose_fix",
    ] = Field(..., description="Action to execute")
    argument: str = Field(default="", description="Action argument")


class FlakySleuthReward(BaseModel):
    score: float
    breakdown: dict[str, Any]
    explanation: str