From cdc123ec2f9043cd4a7e586c1b1843667a08601a Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Thu, 23 Jul 2026 01:10:21 -0500 Subject: [PATCH] fix(computer_use): only disable agent cursor after session handshake Guard the post-start set_agent_cursor_enabled on _session._started so call_tool cannot re-enter session.start() (matches the start_session lifecycle guard). --- tools/computer_use/cua_backend.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/computer_use/cua_backend.py b/tools/computer_use/cua_backend.py index f12ddc2d16b2..546b51a6b41c 100644 --- a/tools/computer_use/cua_backend.py +++ b/tools/computer_use/cua_backend.py @@ -1505,8 +1505,10 @@ class CuaDriverBackend(ComputerUseBackend): # Belt-and-suspenders when --no-overlay is unsupported or ignored: # hide the agent cursor overlay via the session API so macOS idle - # redraw loops cannot keep burning CPU after the first action. - if _cua_no_overlay(): + # redraw loops cannot keep burning CPU after the first action. Only + # once the handshake flipped `_started` — otherwise call_tool would + # re-enter session.start() (see _LIFECYCLE_CALLS). + if _cua_no_overlay() and self._session._started: try: self.set_agent_cursor_enabled(False, cursor_id=self._session_id) except Exception as e: