Spaces:
Sleeping
Sleeping
File size: 1,081 Bytes
e75c8ce 6e72b95 e75c8ce 6e72b95 e75c8ce 6e72b95 e75c8ce 6e72b95 e75c8ce | 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 | """Typed OpenEnv contracts: Action, Observation, State."""
from __future__ import annotations
from typing import Literal
from openenv.core.env_server import Action, Observation, State
from pydantic import BaseModel, ConfigDict, Field
class CacheItem(BaseModel):
model_config = ConfigDict(extra="allow")
key: str
age: int = Field(ge=0)
access_count: int = Field(ge=0)
last_result: str
class CacheAction(Action):
"""Per-step decision for one cache key."""
type: Literal["invalidate", "refresh", "keep"]
key: str
class CacheObservation(Observation):
"""What the agent sees (no hidden TTL / true staleness)."""
items: list[CacheItem] = Field(default_factory=list)
step: int = Field(default=0, ge=0)
task_id: str = ""
final_score: float | None = Field(
default=None,
description="Episode grader output in [0,1] when done=True; else None.",
)
class CacheState(State):
"""Server-visible state (no hidden dynamics)."""
task_id: str = ""
items: list[CacheItem] = Field(default_factory=list)
|