mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-15 00:46:07 +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:
|
||||
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:
|
||||
self.status = MCPSessionStatus.ERROR
|
||||
self.error_message = str(e)
|
||||
|
||||
Reference in New Issue
Block a user