mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-14 08:26:07 +00:00
fix(mcp): survive transient WS transport drops for Box stdio MCP servers (#2303)
* fix(mcp): survive transient WS transport drops for Box stdio MCP servers A Box-backed stdio MCP server (e.g. pab1it0/prometheus) would periodically error on the frontend with Box managed process exited unexpectedly / Failed after 4 attempts once the session had been alive for a while. Root cause: the managed MCP process lives in the Box runtime and SURVIVES a WebSocket transport drop, but _lifecycle_loop treated any monitor completion as a fatal process death. It then ran the finally-block cleanup — which STOPS the still-healthy managed process — and did a full 4-attempt exponential backoff rebuild. Under an occasionally-stalled single-worker event loop the mcp websocket client misses a ping/pong, the transport drops, and this self-inflicted teardown loop is what the user sees. Fixes: - _lifecycle_loop: when the health monitor completes, re-check the real managed-process state. If the process is still running, the transport merely dropped: raise an internal _TransportReconnect signal instead of Box managed process exited unexpectedly. - _lifecycle_loop_with_retry: handle _TransportReconnect as a free, uncounted reconnect (does not consume the fatal retry budget), so a long-lived session survives arbitrarily many transient drops. - finally-block: gate managed-process teardown on a _preserve_managed_process flag so a transport-only reconnect closes just the WS, not the process. - BoxStdioSessionRuntime.initialize: reuse an already-running managed process instead of stopping+rebuilding it (which also re-ran the slow dependency bootstrap); only (re)start when none is running. Adds _managed_process_is_running() helper. Pairs with langbot-plugin-sdk fix adding a server-driven WS heartbeat to the managed-process relay, which prevents most drops in the first place. * style(mcp): ruff format * chore(deps): pin langbot-plugin 0.4.8 for the managed-process WS heartbeat fix --------- Co-authored-by: dadachann <185672915+dadachann@users.noreply.github.com>
This commit is contained in:
@@ -2123,7 +2123,7 @@ requires-dist = [
|
||||
{ name = "ebooklib", specifier = ">=0.18" },
|
||||
{ name = "gewechat-client", specifier = ">=0.1.5" },
|
||||
{ name = "html2text", specifier = ">=2024.2.26" },
|
||||
{ name = "langbot-plugin", specifier = "==0.4.7" },
|
||||
{ name = "langbot-plugin", specifier = "==0.4.8" },
|
||||
{ name = "langchain", specifier = ">=1.3.9" },
|
||||
{ name = "langchain-core", specifier = ">=1.3.3" },
|
||||
{ name = "langchain-text-splitters", specifier = ">=1.1.2" },
|
||||
@@ -2187,7 +2187,7 @@ dev = [
|
||||
|
||||
[[package]]
|
||||
name = "langbot-plugin"
|
||||
version = "0.4.7"
|
||||
version = "0.4.8"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "aiofiles" },
|
||||
@@ -2208,9 +2208,9 @@ dependencies = [
|
||||
{ name = "watchdog" },
|
||||
{ name = "websockets" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/00/6c/850a92cc05583ab71e6ac527ff50fa5f3db43cc16e86f4f6d5ac684da9a8/langbot_plugin-0.4.7.tar.gz", hash = "sha256:16b24d79fc55c0a6b15d901b1134de9e298e2cadab9a9b25c9231f731333ebe9", size = 333867, upload-time = "2026-07-02T16:49:46.258Z" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/7f/f5/1b417a48d329f959a261eaf9a37b26197f18081d2b6f0ef3e4bbab687b81/langbot_plugin-0.4.8.tar.gz", hash = "sha256:e9614be248acf352acb9430d9e154e0abae981575de16812f68282c92a4e42d8", size = 334076, upload-time = "2026-07-03T04:15:28.233Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/c6/f5/a00a929ffb4dcbd958e5f5249516f19ecc720f25f072c9bfda8bbb56851c/langbot_plugin-0.4.7-py3-none-any.whl", hash = "sha256:1364f80fcf448f4503e87d1367af60438abd2cf16e78be6807032cbdb4710a56", size = 220999, upload-time = "2026-07-02T16:49:44.868Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/40/21/46bfa911ab27d6856a3b4363805c4bb8a657500cbc12e1e719d0b3b349dc/langbot_plugin-0.4.8-py3-none-any.whl", hash = "sha256:87c12d9d5579b0ab4dc43c9e559b4d15d7387db8c8b52d476cf27a3de74aedf5", size = 221244, upload-time = "2026-07-03T04:15:27.087Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
Reference in New Issue
Block a user