File tree Expand file tree Collapse file tree
packages/uipath-openai-agents/src/uipath_openai_agents/runtime Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -211,6 +211,11 @@ async def _run_agent(
211211 is_resuming = bool (options and options .resume )
212212
213213 # Get or create session for state persistence
214+ # Close any existing session before creating a new one
215+ if self ._session :
216+ self ._session .close ()
217+ self ._session = None
218+
214219 # SQLiteSession automatically loads existing data from the database when created
215220 if self .storage_path :
216221 self ._session = SQLiteSession (self .runtime_id , self .storage_path )
@@ -487,6 +492,10 @@ async def get_schema(self) -> UiPathRuntimeSchema:
487492
488493 async def dispose (self ) -> None :
489494 """Cleanup runtime resources."""
495+ # Close OpenAI Agents SDK session if it exists
496+ if self ._session :
497+ self ._session .close ()
498+ self ._session = None
499+
490500 # Storage is shared across runtimes and managed by the factory
491501 # Do not dispose it here
492- pass
You can’t perform that action at this time.
0 commit comments