From 33a801429b0e6eac54fca45b25df9dc044358cc3 Mon Sep 17 00:00:00 2001 From: Jonathan Dobson Date: Tue, 29 Jul 2025 21:04:30 -0400 Subject: [PATCH] add some logs for debug_session endpoint (#3056) --- skyvern/forge/sdk/routes/agent_protocol.py | 46 +++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/skyvern/forge/sdk/routes/agent_protocol.py b/skyvern/forge/sdk/routes/agent_protocol.py index 8b5ee3f3..b9d80aa4 100644 --- a/skyvern/forge/sdk/routes/agent_protocol.py +++ b/skyvern/forge/sdk/routes/agent_protocol.py @@ -2048,8 +2048,26 @@ async def get_or_create_debug_session_by_user_and_workflow_permanent_id( workflow_permanent_id=workflow_permanent_id, ) + LOG.info( + "Existing debug session not found, created a new one", + debug_session_id=debug_session.debug_session_id, + browser_session_id=new_browser_session.persistent_browser_session_id, + organization_id=current_org.organization_id, + user_id=current_user_id, # not sure how we feel about logging this + workflow_permanent_id=workflow_permanent_id, + ) + return debug_session + LOG.info( + "Existing debug session found", + debug_session_id=debug_session.debug_session_id, + browser_session_id=debug_session.browser_session_id, + organization_id=current_org.organization_id, + user_id=current_user_id, # not sure how we feel about logging this + workflow_permanent_id=workflow_permanent_id, + ) + browser_session = await app.DATABASE.get_persistent_browser_session( debug_session.browser_session_id, current_org.organization_id ) @@ -2097,7 +2115,24 @@ async def get_or_create_debug_session_by_user_and_workflow_permanent_id( return debug_session else: LOG.info( - "pbs for debug session has expired", + "Browser session for debug session has expired", + debug_session_id=debug_session.debug_session_id, + organization_id=current_org.organization_id, + workflow_permanent_id=workflow_permanent_id, + user_id=current_user_id, + ) + else: + if browser_session: + LOG.info( + "Browser session for debug session has expired, creating a new one", + debug_session_id=debug_session.debug_session_id, + organization_id=current_org.organization_id, + workflow_permanent_id=workflow_permanent_id, + user_id=current_user_id, + ) + else: + LOG.info( + "Browser session did not exist for debug session, creating a new one", debug_session_id=debug_session.debug_session_id, organization_id=current_org.organization_id, workflow_permanent_id=workflow_permanent_id, @@ -2114,4 +2149,13 @@ async def get_or_create_debug_session_by_user_and_workflow_permanent_id( browser_session_id=browser_session.persistent_browser_session_id, ) + LOG.info( + "Updated debug session with new browser session", + debug_session_id=debug_session.debug_session_id, + browser_session_id=browser_session.persistent_browser_session_id, + organization_id=current_org.organization_id, + workflow_permanent_id=workflow_permanent_id, + user_id=current_user_id, + ) + return debug_session