fix(computer_use): reconnect a dead cua-driver session instead of hanging (#55048) - #67138
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the session-hang half of #55048 (Bug 1): a dropped cua-driver MCP connection left the wrapper wedged so every later
list_apps/capturehung forever instead of reconnecting.Root cause
_CuaDriverSession._lifecycle_coroowns the MCP contexts and, on exit, cleared_sessionbut never reset_started. So after a driver crash / connection drop,_startedstayedTrue:_require_started()passed, and the call then operated on aNonesession — a permanent hang from the first MCP blip.Changes
_lifecycle_coro'sfinallynow sets_started = Falseon any exit, so a dead session is re-enterable. Idempotent no-op on the normalstop()path (which already set it false); a plain-bool write is atomic in CPython, so it's safe from the bridge-loop thread without taking the lockstop()may hold.call_tool()re-entersstart()when the session isn't active, rebuilding it before the call. Thestart_session/end_sessionhandshake — driven bystart()/stop()themselves while_startedis in flux — is exempted so bootstrap doesn't recurse.Scope note
This is Bug 1 of #55048. Bug 2 of that issue (expose a foreground
dispatchparam so clicks land on Qt/Electron) already shipped as thedelivery_modework in #67123 — this PR is only the lifecycle-reconnect fix.Validation
test_computer_use_delivery_ladder.py)finallyresets_started;call_toolrestarts a dead session exactly onceInfographic