always return debug sessions that are <30s fresh (#3132)

This commit is contained in:
Jonathan Dobson
2025-08-07 17:08:50 -04:00
committed by GitHub
parent 8471f50fef
commit 4c219b7f05
3 changed files with 47 additions and 0 deletions

View File

@@ -3492,6 +3492,28 @@ class AgentDB:
return DebugSession.model_validate(debug_session)
async def get_latest_debug_session_for_user(
self,
*,
organization_id: str,
user_id: str,
workflow_permanent_id: str,
) -> DebugSession | None:
async with self.Session() as session:
query = (
select(DebugSessionModel)
.filter_by(organization_id=organization_id)
.filter_by(deleted_at=None)
.filter_by(status="created")
.filter_by(user_id=user_id)
.filter_by(workflow_permanent_id=workflow_permanent_id)
.order_by(DebugSessionModel.created_at.desc())
)
model = (await session.scalars(query)).first()
return DebugSession.model_validate(model) if model else None
async def complete_debug_sessions(
self,
*,