File size: 2,315 Bytes
a58e144
 
 
 
 
 
82a272b
 
 
 
a58e144
260ea31
a58e144
 
 
 
 
 
 
 
260ea31
a58e144
 
 
 
 
 
 
 
 
 
82a272b
 
 
a58e144
260ea31
a58e144
82a272b
 
a58e144
 
82a272b
260ea31
 
 
e2d8d59
 
 
 
 
 
 
 
 
 
 
 
a58e144
 
 
 
260ea31
a58e144
 
 
260ea31
 
 
 
 
 
 
e2d8d59
a58e144
 
 
 
260ea31
bac365f
a58e144
 
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
"""
InboxIQ — Pydantic models for the OpenEnv RL interface.
Typed Observation, Action, and Reward models per OpenEnv spec.
"""

from pydantic import BaseModel, Field
from typing import Literal, List, Dict, Any, Optional


class Action(BaseModel):
    """Agent action — choose a triage operation for a specific email."""

    action_type: Literal["open", "delete", "defer", "escalate"] = Field(
        description="The triage action: open (process), delete (remove), defer (delay), escalate (priority)"
    )
    email_id: str = Field(description="Unique identifier of the target email")


class EmailItem(BaseModel):
    """Single email in the inbox observation."""

    id: str
    sender: str = ""
    subject: str = ""
    type: str = "WORK"
    urgency: str = "MEDIUM"
    sentiment: str = "Professional"
    sentiment_confidence: float = 0.5
    spam_score: float = 0.0
    confidence: float = 0.5
    wait: int = 0


class Observation(BaseModel):
    """Environment observation returned after reset/step."""

    inbox: List[Dict[str, Any]] = Field(default_factory=list)
    steps: int = 0
    task: str = "train"
    max_steps: int = 10
    total_reward: float = 0.0
    classifier_stats: Optional[Dict[str, Any]] = None
    reward: float = 0.0
    done: bool = False
    info: Optional[Dict[str, Any]] = None
    error_trace: Optional[str] = Field(
        default=None,
        description="Specific error messages generated by malformed tool calls or invalid state transitions",
    )
    step_feedback: Optional[str] = Field(
        default=None,
        description="Micro-rewards, qualitative hints, or penalties generated immediately after the action",
    )
    html_observation: Optional[str] = Field(
        default=None,
        description="Visual representation of the inbox state as an HTML table for multi-modal agents",
    )


class StepResult(BaseModel):
    """Result returned by the step endpoint."""

    observation: Dict[str, Any]
    reward: float
    done: bool


class State(BaseModel):
    """Environment state tracking episode progress."""

    episode_id: str
    step_count: int
    seed: Optional[int] = None


class GraderResult(BaseModel):
    """Grader score for the current episode."""

    score: float = Field(gt=0.0, lt=1.0)
    total_reward: float
    task: str