smartem_backend.agent_connection_manager#
Agent Connection Management Service
Handles connection health monitoring, instruction expiration, and cleanup for the SmartEM backend-to-agent communication system.
Members
Manages agent connections, health monitoring, and instruction lifecycle.  | 
|
Get the global connection manager instance.  | 
|
Start the global connection manager.  | 
|
Stop the global connection manager.  | 
- class smartem_backend.agent_connection_manager.AgentConnectionManager(db_engine=None, check_interval: int = 30)[source]#
 Manages agent connections, health monitoring, and instruction lifecycle.
Responsibilities: - Monitor connection health and detect stale connections - Handle instruction expiration and retry logic - Clean up inactive sessions and connections - Provide connection statistics and monitoring
Initialize the connection manager.
- Parameters:
 db_engine – Database engine (defaults to global engine)
check_interval – How often to run cleanup tasks (seconds)
- create_session(agent_id: str, acquisition_uuid: str | None = None, name: str | None = None, description: str | None = None, experimental_parameters: dict | None = None) str[source]#
 Create a new agent session.
- Parameters:
 agent_id – Unique identifier for the agent
acquisition_uuid – Associated acquisition UUID (optional)
name – Session name (optional)
description – Session description (optional)
experimental_parameters – Experimental parameters (optional)
- Returns:
 Created session ID
- Return type:
 
- smartem_backend.agent_connection_manager.get_connection_manager() AgentConnectionManager[source]#
 Get the global connection manager instance.