add more logging to debug runtime restarts (#8799)

This commit is contained in:
Robert Brennan 2025-05-29 15:52:13 -04:00 committed by GitHub
parent 0e0687efc3
commit 3f0d8e7f47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 4 deletions

View File

@ -101,7 +101,15 @@ class RemoteRuntime(ActionExecutionClient):
def log(self, level: str, message: str, exc_info: bool | None = None) -> None:
message = f'[runtime session_id={self.sid} runtime_id={self.runtime_id or "unknown"}] {message}'
getattr(logger, level)(message, stacklevel=2, exc_info=exc_info)
getattr(logger, level)(
message,
stacklevel=2,
exc_info=exc_info,
extra={
'session_id': self.sid,
'runtime_id': self.runtime_id,
},
)
@property
def action_execution_server_url(self) -> str:
@ -285,9 +293,10 @@ class RemoteRuntime(ActionExecutionClient):
f'{self.config.sandbox.remote_runtime_api_url}/resume',
json={'runtime_id': self.runtime_id},
)
self.log('info', 'Runtime resumed, waiting for it to be alive...')
self._wait_until_alive()
self.setup_initial_env()
self.log('debug', 'Runtime resumed.')
self.log('info', 'Runtime resumed and alive.')
def _parse_runtime_response(self, response: httpx.Response) -> None:
start_response = response.json()
@ -407,7 +416,7 @@ class RemoteRuntime(ActionExecutionClient):
f'{self.config.sandbox.remote_runtime_api_url}/pause',
json={'runtime_id': self.runtime_id},
)
self.log('debug', 'Runtime paused.')
self.log('info', 'Runtime paused.')
except Exception as e:
self.log('error', f'Unable to pause runtime: {str(e)}')
raise e
@ -420,7 +429,7 @@ class RemoteRuntime(ActionExecutionClient):
f'{self.config.sandbox.remote_runtime_api_url}/stop',
json={'runtime_id': self.runtime_id},
)
self.log('debug', 'Runtime stopped.')
self.log('info', 'Runtime stopped.')
except Exception as e:
self.log('error', f'Unable to stop runtime: {str(e)}')
raise e

View File

@ -90,6 +90,9 @@ async def connect(connection_id: str, environ: dict) -> None:
)
latest_event_id = -1
conversation_id = query_params.get('conversation_id', [None])[0]
logger.info(
f'Socket request for conversation {conversation_id} with connection_id {connection_id}'
)
raw_list = query_params.get('providers_set', [])
providers_list = []
for item in raw_list:
@ -112,6 +115,9 @@ async def connect(connection_id: str, environ: dict) -> None:
user_id = await conversation_validator.validate(
conversation_id, cookies_str, authorization_header
)
logger.info(
f'User {user_id} is allowed to connect to conversation {conversation_id}'
)
conversation_init_data = await setup_init_convo_settings(user_id, providers_set)
agent_loop_info = await conversation_manager.join_conversation(