feat(desktop): batch execute — one round-trip for N actions - #24
Merged
Conversation
The MCP/bridge dispatch overhead, not the SetValue call itself, is the real bottleneck for bulk-input workflows (form fills, Excel cell writes). ValuePattern.SetValue / AXSetValue are already the fast path on both bridges; the cost is paying for N MCP dispatches + N stdio round-trips when an agent drives many cells in sequence. This adds `agentmark_desktop_execute_batch` — pass an array of actions, get them executed inside the bridge in one stdio call. For a 1000-action batch that's ~1 dispatch + ~1 stdio call instead of 1000 of each. Changes: - `DesktopCaptureBackend.executeBatch?()` — optional method; backends without it fall through to a loop of execute() in the plugin handler. - `FixtureBackend.executeBatch` — runs the array; honours on_error. - `WindowsUiaBackend.executeBatch` — calls bridge `execute_batch` method. - `Program.cs HandleExecuteBatch` — single STA invocation processes the entire array; `onError: stop | continue`. - `MacosAxapiBackend.executeBatch` — same pattern, bridge `execute_batch`. - `Dispatcher.swift handleExecuteBatch` — loops actions inside one AXAPI invocation. - Plugin tool `agentmark_desktop_execute_batch` validates every action_id up front; fail-fast on unknown IDs so a bad batch never reaches the backend. Tests (4 new, 330 total): - Batch type-action sequence updates multiple snapshot values. - Fail-fast on unknown action_id does NOT touch the backend. - Empty actions array is rejected. - No snapshot → clear error. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Why
The audit yesterday showed both bridges already use the fast SetValue/AXSetValue path for `type` actions — the per-key keystroke synthesis was already only a fallback. The actual bottleneck for bulk-input workflows ("fill 10k Excel cells", "populate a 500-row form") is the per-call dispatch overhead: each `agentmark_desktop_execute` is one MCP dispatch + one stdio round-trip + one ValuePattern.SetValue. SetValue itself is microseconds; the round-trips dominate.
Result for a 1000-action workflow:
What's not in this PR
Fail-fast semantics
Every `action_id` is resolved against the cached snapshot binding before any backend call. An unknown action_id in position N aborts the entire batch before touching the bridge — guards against partially-corrupted state on ordered workflows. Tested explicitly.
`on_error` controls behavior past the first runtime failure (e.g. element disabled, no longer in tree):
Test plan
🤖 Generated with Claude Code