set status to failed when browser session fails to initially connect (#3101)
This commit is contained in:
@@ -3040,7 +3040,9 @@ class AgentDB:
|
||||
async def update_persistent_browser_session(
|
||||
self,
|
||||
browser_session_id: str,
|
||||
timeout_minutes: int,
|
||||
*,
|
||||
status: str | None = None,
|
||||
timeout_minutes: int | None = None,
|
||||
organization_id: str | None = None,
|
||||
) -> PersistentBrowserSession:
|
||||
try:
|
||||
@@ -3055,7 +3057,12 @@ class AgentDB:
|
||||
).first()
|
||||
if not persistent_browser_session:
|
||||
raise NotFoundError(f"PersistentBrowserSession {browser_session_id} not found")
|
||||
persistent_browser_session.timeout_minutes = timeout_minutes
|
||||
|
||||
if status:
|
||||
persistent_browser_session.status = status
|
||||
if timeout_minutes:
|
||||
persistent_browser_session.timeout_minutes = timeout_minutes
|
||||
|
||||
await session.commit()
|
||||
await session.refresh(persistent_browser_session)
|
||||
return PersistentBrowserSession.model_validate(persistent_browser_session)
|
||||
|
||||
@@ -2,6 +2,12 @@ from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
FINAL_STATUSES = ("completed", "failed")
|
||||
|
||||
|
||||
def is_final_status(status: str | None) -> bool:
|
||||
return status in FINAL_STATUSES
|
||||
|
||||
|
||||
class PersistentBrowserSession(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
Reference in New Issue
Block a user