fix(computer_use): add fallback when list_windows(on_screen_only=True) returns empty (#32766)#33054
Open
Tranquil-Flow wants to merge 1 commit into
Open
Conversation
…) returns empty (NousResearch#32766) When the cua-driver's is_on_screen detection is unreliable (e.g. on certain window managers, virtual desktops, or when no window is focused), list_windows(on_screen_only=True) returns zero windows. Previously, capture() gave up immediately with an empty 0x0 result, breaking auxiliary vision routing and making computer_use unusable on affected systems. Add a fallback: retry list_windows without the on_screen_only filter when the primary call returns empty. The fallback applies client-side on_screen filtering so the behavior matches the primary path as closely as possible. Fixes NousResearch#32766.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
What does this PR do?
Fixes fragility in
CuaDriverBackend.capture()wherelist_windows(on_screen_only=True)can return zero windows due to unreliableis_on_screendetection in the underlying cua-driver. This causes the entirecomputer_usetoolset to fail hard, breaking auxiliary vision routing for text-only main models.Fix: Adds a fallback retry without the
on_screen_onlyfilter when the primary call returns empty. The fallback applies client-sideis_on_screenfiltering. If the fallback also returns empty, a graceful emptyCaptureResultis returned.Related Issue
Fixes #32766
Type of Change
Changes Made
tests/tools/test_cua_backend_fallback_32766.py(+156): 4 focused regression teststools/computer_use/cua_backend.py(+31): Fallback retry when primary on_screen_only returns empty, with client-side filtering and identical normalizationHow to Test
python3 -m pytest tests/tools/test_cua_backend_fallback_32766.py tests/tools/test_computer_use.py -v -o "addopts="78 tests passed (4 new + 74 existing). Fail-without-fix proven: 3/4 new tests fail without production change.
Related PRs
app=...targeting fallback — complementary narrower fix. This PR covers the broader zero-window case regardless of app targeting.Checklist: