@@ -144,7 +144,9 @@ class AgentSession:
await self.security_analyzer.close()
self.loop.call_soon_threadsafe(self.loop.stop)
- self.thread.join()
+ if self.thread:
+ # We may be closing an agent_session that was never actually started
+ self.thread.join()
self._closed = True