feat(sdk): add local desktop with long polling#104
Conversation
7cd9325 to
314cbd2
Compare
314cbd2 to
842ce02
Compare
842ce02 to
74756b1
Compare
74756b1 to
080e475
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 080e475. Configure here.
| await asyncio.sleep(0.5 * (attempt + 1)) | ||
| logger.error( | ||
| "Failed to deliver result for command %s after %s attempts", command_id, cfg.post_result_retries + 1 | ||
| ) |
There was a problem hiding this comment.
Failed results may rerun commands
Medium Severity
_post_result logs and returns after exhausting retries without surfacing failure to _process_commands or the poll loop. The sidecar then keeps polling, so the server may redeliver the same command and local actions like clicks or run_command can run more than once.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 080e475. Configure here.
| if pyautogui is None: | ||
| raise ImportError( | ||
| "Local desktop control requires pyautogui and pynput. Install with: pip install 'hai-agents[desktop]'" | ||
| ) |
There was a problem hiding this comment.
pynput required but unused
Low Severity
The desktop extra and _LocalDesktopDriver docs/error text require pynput, but the module only imports and uses pyautogui. Installations pull native pynput dependencies without any runtime use in this codepath.
Reviewed by Cursor Bugbot for commit 080e475. Configure here.



Summary
Adds a new
[desktop]optional extra that lets users run a local sidecar on their machine and have H agents control it remotely via mouse, keyboard, and screenshots.New public API:
LocalDesktopClient/LocalDesktopClientConfig— polls AgP for incoming desktop commands and executes them locally usingpyautoguisession_id_from_environment_id(environment_id, api_key)— derives the deterministic routing UUID that ties the sidecar to an agent sessionUsage:
Install:
pip install "hai-agents[desktop]"Note
High Risk
Remote agents can drive real input, filesystem, and shell on the host when the sidecar runs with a valid API key—high blast radius despite being an intentional feature.
Overview
Adds a
[desktop]optional extra (pyautogui,pynput) and a newlocal_desktopmodule so a machine can run an async sidecar that long-polls AgP for commands and executes them locally.Public API:
LocalDesktopClient/LocalDesktopClientConfig, plussession_id_from_environment_id(UUID5 fromenvironment_id+api_key) exported fromhai_agentsfor routing agent sessions to the same machine without manual ID coordination.The client ensures/creates an interactive trajectory, polls
GET .../commands, dispatches named driver methods (mouse, keyboard, screenshots, file I/O,run_commandwith detach on POSIX/Windows), serializes results (e.g. PNG as base64), and posts back with retries and reconnect backoff. Tests stubpyautoguiinconftestfor headless CI; lockfile picks up desktop transitive deps and minor dev bumps (ruff, rich).Reviewed by Cursor Bugbot for commit 080e475. Bugbot is set up for automated code reviews on this repo. Configure here.