File size: 1,173 Bytes
b641d3d | 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 | from typing import Any
from pydantic import BaseModel, Field, field_validator
class SystemMetrics(BaseModel):
gateway_success_rate: float = Field(..., ge=0.0, le=1.0)
gateway_p99_latency_ms: float = Field(..., ge=0.0)
queue_depth: int = Field(..., ge=0)
worker_restart_count: int = Field(..., ge=0)
consumer_stall_count: int = Field(..., ge=0)
class Observation(BaseModel):
command_output: str = Field(
..., description="stdout+stderr from the last executed command"
)
metrics: SystemMetrics
process_status: dict[str, str] = Field(default_factory=dict)
class Action(BaseModel):
command: str = Field(..., description="Single bash command to execute")
@field_validator("command")
@classmethod
def command_must_not_be_empty(cls, value: str) -> str:
if not value.strip():
raise ValueError("command must not be empty")
return value
class Reward(BaseModel):
value: float = Field(..., ge=0.0, le=1.0)
class StepResult(BaseModel):
observation: Observation
reward: float = Field(..., ge=0.0, le=1.0)
done: bool
info: dict[str, Any] = Field(default_factory=dict)
|