fix(computer-use): fail unverified CUA actions closed - #59730
Closed
bbopen wants to merge 1 commit into
Closed
Conversation
This was referenced Jul 6, 2026
bbopen
force-pushed
the
codex/fix-cua-action-verification
branch
from
July 6, 2026 15:55
352e239 to
cdd9b29
Compare
teknium1
reviewed
Jul 15, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the focused CUA evidence. The false-success portion remains a real current-main bug: tools/computer_use/cua_backend.py:2327-2335 derives success solely from isError and discards structuredContent for string responses.
Problems
- The keyboard forwarding hunk is superseded and would weaken current behavior if applied as written. Current main requires a window ID and fails closed at
tools/computer_use/cua_backend.py:1895-1921; the PR only forwards it when present, retaining a PID-only dispatch path. - The keyboard tests are now redundant with
tests/tools/test_computer_use.py:2542-2614, landed in2b6897f982d(#63725).
Suggested changes
- Salvage the focused
_action()metadata/fail-closed logic and add its regression tests. - Keep the stronger current-main keyboard routing implementation unchanged.
Automated hermes-sweeper review.
| @@ -1679,7 +1679,10 @@ def type_text(self, text: str) -> ActionResult: | |||
| if pid is None: | |||
| return ActionResult(ok=False, action="type_text", | |||
| message="No active window — call capture() first.") | |||
Contributor
There was a problem hiding this comment.
Do not salvage this keyboard hunk as-is. Current main now fails closed when _active_window_id is absent; this conditional forwarding would retain PID-only keyboard dispatch in that state. Keep the current-main guard and limit salvage to _action() verification handling.
Contributor
Author
|
Closing as this was superceded by #67123 |
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?
Fail CUA-backed
computer_useactions closed whencua-driverreportsstructuredContent.verified: false, and preserve the structured action metadata inActionResult.metaeven when the human-readabledatafield is a string.The same change also sends the active
window_idon keyboard actions (type_text,press_key,hotkey) whencapture()has already resolved a target window. That keeps keyboard input aligned with the same window-local targeting contract already used by capture,set_value, and element actions.This is related to #59387, which preserves structured action metadata and adds
window_idfor coordinate pointer actions. It does not duplicate that PR completely: #59387 still returnsok=Trueforverified:falseand does not passwindow_idfor bare active-windowtype_text/key actions.Related Issue
Fixes #59731
Related: #59387
Type of Change
Changes Made
tools/computer_use/cua_backend.pystructuredContentinto action metadata for all CUA actionsActionResult.ok=FalsewhenstructuredContent.verified is Falsewindow_idontype_text,press_key, andhotkeycalls when availabletests/tools/test_computer_use.pyverified:falsefail-closed behaviortype_text,press_key, andhotkeycarrywindow_idHow to Test
Reproduced on latest
origin/mainat7426c09beewith an isolated fake CUA session:type_textandhotkeyreturnedresult_ok: true, empty metadata, and nowindow_id, even though the simulated driver payload containedstructuredContent.verified: false.Patched commit
cdd9b29eafreturnsresult_ok: false, preservesverified:false/effect/pathinmeta, and sendswindow_id: 456for the same active-window keyboard calls.Validation run locally:
Non-destructive live smoke on macOS with
cua-driver 0.7.0also passed: backend start,list_apps, andcapture(mode="som")completed successfully.Real action smoke on macOS with a disposable Tk text window:
cua-driverlist_windows(app_name: "python", concretepidandwindow_id).backend.type_text(...)sent the activewindow_idand the Tk process observed the typed text land in the widget.structuredContent.verified: false(path: "key_events",effect: "unverifiable"), so the patched branch returnedActionResult.ok == Falsewhile preserving that metadata.cua-driverstill returnedverified:false(path: "key_events_fg"). This is a driver verification limitation; the wrapper should not report it as confirmed success.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) - N/Acli-config.yaml.exampleif I added/changed config keys - N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows - N/AScreenshots / Logs
Baseline
origin/mainsynthetic repro:{ "type_text": {"result_ok": true, "result_meta": {}, "call_args": {"pid": 123, "session": "hermes-repro-fake", "text": "hello"}}, "hotkey": {"result_ok": true, "result_meta": {}, "call_args": {"pid": 123, "session": "hermes-repro-fake", "keys": ["cmd", "a"]}} }Patched synthetic repro:
{ "type_text": {"result_ok": false, "result_meta": {"verified": false, "effect": "unverifiable", "path": "key_events"}, "call_args": {"pid": 123, "session": "hermes-repro-fake", "text": "hello", "window_id": 456}}, "hotkey": {"result_ok": false, "result_meta": {"verified": false, "effect": "unverifiable", "path": "key_events"}, "call_args": {"pid": 123, "session": "hermes-repro-fake", "keys": ["cmd", "a"], "window_id": 456}} }