Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/pydo/agents/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,16 @@ def agent_kind(self) -> Optional[str]:
get = getattr(info, "get", None)
return get("agent_kind") if get else None

@property
def size_slug(self) -> Optional[str]:
"""The sandbox size slug this session's sandbox actually booted at
(e.g. ``"mars-2vcpu-4gb"``), or ``None`` if unknown (a session that has
not reached a sandbox yet, or one created before this field existed).
"""
info = self.info
get = getattr(info, "get", None)
return get("size_slug") if get else None

@property
def openai_session_id(self) -> Optional[str]:
info = self.info
Expand Down
10 changes: 10 additions & 0 deletions src/pydo/aio/agents/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,16 @@ def agent_kind(self) -> Optional[str]:
get = getattr(info, "get", None)
return get("agent_kind") if get else None

@property
def size_slug(self) -> Optional[str]:
"""The sandbox size slug this session's sandbox actually booted at
(e.g. ``"mars-2vcpu-4gb"``), or ``None`` if unknown (a session that has
not reached a sandbox yet, or one created before this field existed).
"""
info = self.info
get = getattr(info, "get", None)
return get("size_slug") if get else None

@property
def openai_session_id(self) -> Optional[str]:
info = self.info
Expand Down
34 changes: 34 additions & 0 deletions tests/agents/test_session_highlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,31 @@ def test_hitl_none_leaves_prompt_unresolved():
assert sessions.resolved == []


# ---------------------------------------------------------------------------
# Read-model properties
# ---------------------------------------------------------------------------


def test_size_slug_reads_from_session_info():
agent = AgentSession(
_FakeSessions([]),
"s1",
raw={
"session": {
"status": "ready",
"agent_kind": "AGENT_KIND_OPENCODE",
"size_slug": "mars-2vcpu-4gb",
}
},
)
assert agent.size_slug == "mars-2vcpu-4gb"


def test_size_slug_is_none_when_absent():
agent = AgentSession(_FakeSessions([]), "s1", raw={"session": {"status": "ready"}})
assert agent.size_slug is None


# ---------------------------------------------------------------------------
# Lifecycle
# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -339,3 +364,12 @@ async def test_async_context_manager_destroys():
async with AsyncAgentSession(sessions, "s1") as agent:
assert agent.session_id == "s1"
assert sessions.destroyed


def test_async_size_slug_reads_from_session_info():
agent = AsyncAgentSession(
_FakeAsyncSessions([]),
"s1",
raw={"session": {"status": "ready", "size_slug": "mv-8vcpu-16gb"}},
)
assert agent.size_slug == "mv-8vcpu-16gb"
Loading