mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-17 16:00:59 +00:00
fix(mcp): set _preserve_managed_process before finally in cold-start path (#2309)
_ColdStartRetry was caught in _lifecycle_loop_with_retry which set _preserve_managed_process = True — but by then the finally block inside _lifecycle_loop had already run and called _cleanup_box_stdio_session(), stopping the live managed process (return_code=143 SIGTERM). The cold-start retry then restarted a fresh process, eliminating the warm-up advantage. Fix: add an explicit except _ColdStartRetry in _lifecycle_loop that sets _preserve_managed_process = True before re-raising. The finally block then sees the flag and skips stop_managed_process, leaving the live process untouched for the next handshake attempt. Co-authored-by: dadachann <185672915+dadachann@users.noreply.github.com>
This commit is contained in:
@@ -439,6 +439,12 @@ class RuntimeMCPSession:
|
|||||||
else:
|
else:
|
||||||
await self._shutdown_event.wait()
|
await self._shutdown_event.wait()
|
||||||
|
|
||||||
|
except _ColdStartRetry:
|
||||||
|
# Cold-start in progress: set the preserve flag BEFORE the finally
|
||||||
|
# block runs so it does not stop the live managed process. The outer
|
||||||
|
# _lifecycle_loop_with_retry will reuse it on the next attempt.
|
||||||
|
self._preserve_managed_process = True
|
||||||
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.status = MCPSessionStatus.ERROR
|
self.status = MCPSessionStatus.ERROR
|
||||||
self.error_message = str(e)
|
self.error_message = str(e)
|
||||||
|
|||||||
Reference in New Issue
Block a user