Files
LangBot/tests/unit_tests
Hyu bf3c96026b fix(mcp): fix cold-start connection drop by using lexically-intact owner exit stack (#2307)
The previous _TransferredStack approach broke anyio lexical context:
websocket_client/ClientSession use anyio task groups whose cancel scope is
bound to the frame that entered them. Deferring their aclose via a transferred
exit stack left the underlying memory streams closed once initialize() returned,
so the very next request (refresh -> list_tools) failed with Connection closed.

New design:
- Attach on the owner exit stack (same task as the serve loop, lexically intact)
- A cold-starting process makes initialize() fail; signal _ColdStartRetry up to
  the outer retry loop, which reuses the live process without consuming retry budget
- _lifecycle_loop_with_retry handles _ColdStartRetry like _TransportReconnect:
  preserves process, no fatal budget, backs off 2s and retries
- Two new unit tests: cold-start raises _ColdStartRetry (not fatal) when process
  is alive; raises fatal error when process has actually exited

Co-authored-by: dadachann <185672915+dadachann@users.noreply.github.com>
2026-07-03 14:58:40 +08:00
..
2026-06-16 11:22:29 +08:00
2026-06-16 11:22:29 +08:00
2026-06-16 11:22:29 +08:00
2026-06-16 11:22:29 +08:00
2026-06-16 11:22:29 +08:00
2026-06-16 11:22:29 +08:00
2026-06-16 11:22:29 +08:00
2026-06-16 11:22:29 +08:00
2026-05-16 12:05:54 +08:00
2026-06-03 11:12:39 +08:00