AI Agent Computer Control: Engineering the Last Mile of Office Automation

    This article explores how to engineer computer control for AI agents, closing the last mile of office automation where traditional APIs fall short. It presents a four-layer reference architecture (perception, decision, execution, and skills), a reusable skill specification, an iterative observe-execute-compare-refine loop, and essential safety and stability practices. Readers will learn how to turn one-off demos into governed, auditable, and rollback-capable automation assets, along with a three-tier evaluation approach and a practical adoption path.

    1. The Problem: Why Computer Control Is the Last Mile of Office Automation

    Over the past two years, the capability frontier of AI agents has been pushed mainly by a single thread: code generation. But real knowledge work does not happen only inside an editor. Most tasks are spread across desktop applications, browser pages, internal systems, and local files. Many systems are only partially open, with no stable external interface, or with APIs that cover just a subset of their functionality. The remaining steps still require a human to click a mouse. The result is an awkward situation: an agent can produce an excellent plan, yet get stuck at the very last action.

    Closing this gap matters on three levels:

    1. More complete context. The interface is the de facto data outlet for many business systems. Tables, charts, and status labels on screen are often closer to what a person actually sees than the fields returned by an API.
    2. A more complete task loop. Moving from “offering a suggestion” to “getting the job done” no longer requires a human to shuttle information in between.
    3. More realistic long-tail coverage. Interfaces always lag behind the UI, while the UI covers long-tail scenarios. The two complement rather than replace each other.

    It is worth stressing that the goal of this approach is not to make the model “better at clicking a mouse,” but to engineer interface operations: observable, replayable, verifiable, and rollback-capable.

    2. Capability Layers: A Practical Reference Architecture

    Splitting computer control into four layers, with explicit contracts decoupling each layer, is the key to controlling complexity.

    • Perception layer: Converts the screen into structured information. This includes reading window and control trees, image recognition, and diff comparison (before/after frames, region cropping, OCR text extraction).
    • Decision layer: Breaks a natural-language goal into a sequence of actions. It emphasizes “observe before acting,” where every step is based on the latest observation rather than a one-shot plan laid out to the end.
    • Execution layer: Mouse and keyboard events, clipboard, file read/write, application launch, and window management. All actions must be idempotent or compensable.
    • Skill layer: Encapsulates high-frequency, stable operation sequences into reusable units, each with preconditions, postcondition checks, and failure handling.

    The direct benefit of this layering: swapping the model does not affect the execution layer; changing the operating system only affects execution-layer adaptation; and the skill layer becomes a team asset that keeps accumulating.

    3. Skill Encapsulation: Turning a One-Off Demo into a Reusable Asset

    The most valuable part of the original practice was not any single impressive render, but the fact that “the same set of skills completed two completely different tasks within a single day.” This shows the skill encapsulation granularity was chosen well.

    A qualified skill description should include at least:

    1. skill:
    2. name: parametric-3d-build
    3. version: 1.0
    4. inputs:
    5. - reference_images: list[path] # reference images from multiple views
    6. - target_view_count: int
    7. preconditions:
    8. - app_running: true
    9. - viewport_visible: true
    10. steps:
    11. - observe_scene() # read the current scene state
    12. - write_script(params) # generate a parametric modeling script
    13. - render_previews() # low-resolution fast previews
    14. - compare_and_refine() # compare against reference images and iterate
    15. postconditions:
    16. - object_count > 0
    17. - preview_rendered: true
    18. rollback:
    19. - restore_scene_snapshot()

    The design points come down to this: previews must be fast, iterations must be short, and checks must be automatic. Compressing a render from minutes to seconds gives the agent a chance to perform multiple rounds of self-correction within a single task; writing checks as postconditions is what prevents “looks done but actually isn’t.”

    4. The Iteration Loop: Observe, Execute, Compare, Refine

    The engineering workflow from reference image to finished product can be abstracted into a four-step loop:

    1. Anchor with multiple views. First generate or collect references of the same object from multiple angles to avoid the proportion distortion caused by a single view.
    2. Quantify rather than eyeball. Use pixels and known dimensions to compute conversions, turning “looks about right” into calculable parameters.
    3. Model in layers. Generate the main structure, attached components, and detail decorations in batches, ensuring the overall shape is accurate first, then adding details.
    4. Compare at fixed points and converge. Render one reference view at a time, list the differences, and eliminate them round by round.

    The most instructive part here is that “the difference list is produced by the executing party itself.” Having the agent proactively list unfinished items when wrapping up (for example, a missing streamlined shell, unbuilt railings, or overly flat water texture) is an order of magnitude more efficient than humans picking out errors after the fact, and it makes quality assessment evidence-based.

    5. Controllability and Safety: Caging the Risk

    Interface control carries side effects by nature, so safety design cannot be a patch; it must be an upfront constraint:

    • Least privilege: Grant only the directories and application scope needed to complete the task; sensitive directories are read-only by default.
    • Action allowlist and dangerous-action interception: Deletion, bulk overwrite, outbound sending, and payment-type operations require explicit confirmation.
    • Snapshots and rollback: Save a scene or file snapshot before execution, with one-click restore on failure.
    • Full-chain audit: Leave a trace of every observation and action, supporting replay and root-cause location.
    • Human confirmation points: Insert confirmation before irreversible operations, returning the final decision to the human.
    • Credential isolation: Account passwords never enter the model context; they are injected through a controlled credential channel.

    6. Engineering Details: Stability Comes from Constraints, Not Luck

    • Waiting strategy: Use state-condition polling instead of fixed delays to avoid fragile scripts that “sleep three seconds then click.”
    • Dual channel of coordinates and controls: Prefer control-based location, with image coordinates as a fallback.
    • Resolution and scaling normalization: Unify the coordinate system across multiple monitors and different scaling ratios.
    • Classified failure handling: Distinguish “element not found,” “insufficient permissions,” and “application not responding,” then retry, escalate, or terminate accordingly.
    • Cost control: Use low sampling for previews and high sampling only for the final output; checkpoint long tasks in segments to avoid a full rerun.

    7. Evaluation: How to Prove It Really Works

    A demo without evaluation is not trustworthy. It is recommended to build a three-tier evaluation:

    1. Unit level: Success rate and time cost of a single skill in a fixed environment.
    2. Task level: Completion rate, number of human interventions, and number of rollbacks for an end-to-end task.
    3. Robustness level: Performance degradation under resolution changes, window occlusion, and network fluctuations.

    Beyond metrics, be sure to keep visual evidence such as “side-by-side comparison images” so results can be reviewed by a third party.

    8. Adoption Advice and Extensions

    For teams that want to build this capability, the recommended path is: start by skill-izing two or three high-frequency, low-risk scenarios; abstract the perception and execution layers into a unified interface; then gradually introduce snapshots, audit, and confirmation mechanisms; and finally connect unified scheduling with monitoring and alerting, turning task success rate, average time cost, and failure-reason distribution into an observable dashboard. When elastic compute is needed, a container platform can host stateless executors, object storage can hold snapshots and artifacts, and log and monitoring services can provide full-chain tracing.

    Once interface control is truly engineered, the gap between an agent and an advanced general-purpose model no longer depends on “whether it can click,” but on the depth of the skill library and the maturity of the governance mechanisms. That is the realistic answer to getting through the last mile of office automation.