Skip to content

fix(computer): prevent stale, replayed, and post-cancel desktop actions - #103422

Merged
steipete merged 6 commits into
mainfrom
codex/computer-use-hardening
Jul 10, 2026
Merged

steipete merged 6 commits into
mainfrom
codex/computer-use-hardening

Conversation

@steipete

@steipete steipete commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #103335
Related: #97333
Follow-up to #102776

AI-assisted with Codex; the maintainer reviewed and understands the changes.

What Problem This Solves

The initial macOS computer-use implementation could accept desktop input whose authority had become stale. A replaced screenshot, display reconnect, transport replay, route replacement, or cancellation race could duplicate an action, retarget screenshot coordinates, start queued work after revocation, or leave a synthetic mouse button held.

Why This Change Was Made

This hardens the full screenshot-to-input path instead of adding another approval layer:

  • bind coordinate actions to the exact sanitized screenshot image delivered to the model, its frameId, physical display identity, geometry, screen index, and reference width;
  • keep image-bearing computer calls directly model-visible in Codex and fail closed for text-only, sandboxed, side-question, compacted, or undelivered-image paths;
  • preserve provider tool-call identity across parallel OpenAI Responses, Mistral, Codex, and Copilot streams;
  • deduplicate replayed node requests with in-flight receipts, then bind results and runtime events to the exact route and socket generation;
  • recheck gateway policy after wake/routing changes and keep generic node invocation from bypassing computer.act policy;
  • serialize macOS action execution, cancellation, lifecycle revocation, held-input release, endpoint replacement, pause, disable, and termination cleanup;
  • keep /phone arm all from silently authorizing desktop control; /phone arm computer remains explicit and reload-safe.

User Impact

Computer control remains off and disarmed by default. Once deliberately exposed and armed, coordinate input now fails closed when the model did not receive the exact screenshot, the physical display changed, the request was replayed, or the active node lifecycle lost authority. Cancellation and route replacement complete held-input cleanup before successor work is admitted.

No new config surface or protocol-version bump is introduced. Documentation covers tool policy, explicit arming, frame identity, persistent authorization, Codex direct-tool behavior, and troubleshooting; release-note context remains in this PR for release automation.

Evidence

  • Blacksmith Testbox check:changed (all selected lanes): lease tbx_01kx52gykb4dca2664gda48vy8 / jade-prawn, succeeded in 4m30.529s. Typecheck, core/extension/script oxlint, runtime import cycles, generated guards, and repository policy guards were green.
  • Final CI regression repair on Blacksmith Testbox tbx_01kx58ewe7bkhck3pcy3kzwg51 / violet-crab: nodes-utils.test.ts passed 5/5 and targeted oxfmt passed; the same AbortSignal is proven through both the current node list and legacy fallback.
  • Isolated macOS source checkout: 77 tests across ComputerActionServiceTests, MacNodeModeCoordinatorTests, GatewayChannelDisconnectTests, GatewayConnectionControlTests, and MenuContentSmokeTests passed. The cancellation regression delays the MainActor cleanup hop, makes the first mouse-up fail, and proves cancellation waits for a successful retry before settling.
  • OpenClawKit route/session focus on clawmac: 45 tests passed, including captured route-bound result/event rejection after route replacement. Earlier geometry/action/coordinator focused runs also passed.
  • Focused TypeScript proof passed for provider streams (393 tests), computer/agent policy, Codex dynamic tools, Copilot compaction, phone-control leases, gateway routing, and policy conformance.
  • Static proof: git diff --check; SwiftFormat and swiftc -parse; native i18n inventory (entries=2869 changed=false); docs map; targeted oxfmt/oxlint.
  • Fresh final autoreview after the CI repair: no actionable findings; overall patch correct (0.97 confidence).
  • Dependency contract inspection: Codex spec_plan.rs:204-229, spec_plan.rs:450-510, tool_output.rs:223-243, dynamic.rs:150-213, and thread.rs:56-90; Mistral SDK omitted-index default at @mistralai/mistralai/src/models/components/toolcall.ts:34.

Known evidence gap: a source-blind autonomous GUI run remains blocked because clawmac has no already-running isolated patched app plus isolated Gateway/port and safe test window; production /Applications/OpenClaw.app and its Gateway were intentionally untouched. The validator reported 0 pass, 0 fail, 6 blocked. Closing that black-box loop requires a GUI/VNC session and isolated signed app runtime.

No visual diff.

@steipete
steipete requested a review from a team as a code owner July 10, 2026 05:27
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: macos App: macos gateway Gateway runtime cli CLI command changes security Security documentation docker Docker and sandbox tooling agents Agent runtime and tooling extensions: phone-control extensions: codex plugin: file-transfer extensions: policy extensions: copilot size: XL maintainer Maintainer-authored PR labels Jul 10, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready at exact head 70b8d2bc65696a5365dcc858b97be3f851e91ad1.

Proof:

  • Hosted CI run 29071850534: success, 58/58 jobs, including the repaired compact Node shard.
  • Blacksmith Testbox jade-prawn (tbx_01kx52gykb4dca2664gda48vy8): pnpm check:changed passed in 4m30.529s, including typecheck, oxlint shards, runtime import cycles, and repository guards.
  • Blacksmith Testbox violet-crab (tbx_01kx58ewe7bkhck3pcy3kzwg51): corepack pnpm test src/agents/tools/nodes-utils.test.ts passed 5/5 and corepack pnpm exec oxfmt --check src/agents/tools/nodes-utils.test.ts passed.
  • Isolated macOS proof: 77 focused native tests passed across computer action, node lifecycle, Gateway disconnect/control, menu smoke, and snapshot generation; clawmac OpenClawKit route/session focus passed 45 tests.
  • Fresh final autoreview after the CI repair: no actionable findings; patch correct at 0.97 confidence.
  • OPENCLAW_TESTBOX=1 scripts/pr prepare-run 103422: complete; hosted exact-head gates accepted.

Known proof gap remains documented in the PR body: the source-blind autonomous GUI loop needs an isolated signed app, isolated Gateway/port, and GUI/VNC session. Production clawmac app and Gateway were intentionally untouched; this is not a code-gate failure.

@steipete
steipete merged commit 4617728 into main Jul 10, 2026
107 checks passed
@steipete
steipete deleted the codex/computer-use-hardening branch July 10, 2026 05:48
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 10, 2026
…ns (openclaw#103422)

* fix(ai): preserve streamed tool-call identity

* fix(computer): bind actions to current tool authority

* fix(macos): serialize computer control lifecycle

* docs(computer): document hardened control contract

* chore: follow release-owned changelog policy

* test(agents): cover node list cancellation
yetval added a commit to yetval/openclaw that referenced this pull request Jul 17, 2026
… rebuilds

Gateway tools.invoke (RPC and POST /tools/invoke) resolves a fresh tool set
on every call, so the computer tool's held-button cross-node retarget guard
from openclaw#103422 lived in closure state that never survived to the next call: a
second left_mouse_down aimed at another node was dispatched while the first
node's button stayed held. The MCP loopback surface hit the same defect
whenever its 30-second tool cache rebuilt.

The mutable guard state (target/frame affinity, held-button target, input
serialization queue) moves into an injectable ComputerToolInvocationState.
The agent path is unchanged and keeps per-instance state.
resolveGatewayScopedTools, the shared chokepoint behind all gateway tool
surfaces, injects a per-session provider backed by a bounded registry: keyed
by session key, 64-session LRU cap, 15-minute sliding TTL, entries created
only when the computer tool executes. No tool instances are cached and state
never crosses session keys.

Closes openclaw#104113
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: macos App: macos cli CLI command changes docker Docker and sandbox tooling docs Improvements or additions to documentation extensions: codex extensions: copilot extensions: phone-control extensions: policy gateway Gateway runtime maintainer Maintainer-authored PR plugin: file-transfer security Security documentation size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Computer control can replay or continue stale desktop input

1 participant