AI Agents Operating Computers: The Shift from Fixed Instructions to Code Execution
This article examines a fundamental divide in how AI agents operate computers: fixed batch actions versus code execution. Using a spreadsheet task where one model silently solved only 85 of 125 problems, it explains why fixed instructions fail quietly, the four engineering benefits of code execution, a layered closed-loop architecture for deployment, and key risk controls such as least privilege, idempotency, and human approval gates.
1. A Real Task That Exposes the Divide
Consider a task: solve 125 problems on a spreadsheet. One model generates a program that looks structurally complete, with loops, function encapsulation, and result printing, and finally outputs “Computed answers: 85.” The problem is that the sheet has 125 problems, and the rows containing the remaining 40 were never included in the program’s scan range. More critically, the model itself does not notice the gap and still believes the task is done.
Give the same task to another model and the path is clearly different: it first implements a general-purpose solving function, validates it against several official samples, confirms the logic is correct, then dynamically identifies all qualifying problem rows in the sheet, completes all 125 problems, and summarizes the results.
This is not simply a matter of “which one is smarter,” but a systematic difference between two execution paradigms: one fixes the action sequence at generation time; the other defers decisions to runtime, letting program state drive subsequent behavior. Understanding this difference is the prerequisite for building reliable automation.
2. The Essential Difference Between Two Interaction Paradigms
The default approach for computer-use agents is “look at the screen, issue instructions”: capture an image of the interface, have the model recognize elements, then output click coordinates and input text. This can be called pure GUI interaction, and its actions are essentially batch actions—the model generates a fixed sequence of operations all at once, such as “click A, type B, click C.” These instructions are fully determined the moment they are generated and cannot be adjusted based on intermediate results during execution.
Code execution mode is different. The model outputs a real program that can include conditionals (close a popup if one appears), loops (fill three fields for each row in a table), and validation (check whether the state actually became “Saved”). The program decides what to do next only when it reaches each step.
An everyday analogy: with batch instructions, you must write out in advance a detailed checklist of exactly where to click and what to type at every step, and the assistant executes mechanically, continuing even if the precondition for step three does not hold. With code execution, you only provide rules—open each record one by one, check the status, update if pending, skip if already processed, and summarize a report at the end. The fragility of the former comes from “decisions made upfront”; the robustness of the latter comes from “decisions deferred.”
3. Why Fixed Instructions Fail Silently
The most dangerous aspect of the fixed-instruction mode is not throwing an error, but doing less without reporting anything. Completing only 85 of the 125 problems above is typical: the program is syntactically correct, runs without exceptions, and outputs in the proper format, but its coverage does not match the real requirement. This kind of silent failure usually stems from three points:
- Implicit scope assumptions: The model assumes data is neatly arranged and does not handle real-world structures such as blank rows, merged cells, and section headers.
- No post-hoc validation: It only verifies that “the program runs,” not that “the result count equals the expected total.”
- No self-audit mechanism: It never compares the set of “items that should be processed” against the set of “items actually processed,” so the gap cannot be exposed.
The engineering fix is to upgrade validation from “process correctness” to “result completeness”: first count the total to be processed, then reconcile the total processed at the end, and output a list of uncovered ranges.
Illustrative pseudocode:
targets = detect_target_rows(sheet) # dynamically identify target rowsassert len(targets) == expected_total # completeness pre-checkresults = [solve(row) for row in targets]report = summarize(results)assert report.processed == expected_total, report.missing_ranges
4. Four Engineering Benefits of the Code Execution Paradigm
- Decidable: Runtime branching makes interface state an input to decisions, so popups, loading states, and permission prompts can be handled explicitly rather than relying on a fixed order and luck.
- Loopable: Facing hundreds or thousands of homogeneous records, loops and batch processing are a natural fit, avoiding the context and stability pressure caused by linear growth of the action sequence.
- Verifiable: Programs can embed assertions and sampled re-checks, turning “is it done?” into a computable, assertable metric.
- Reusable: Once a general function passes validation against samples, it can be migrated to similar tasks, accumulating as an asset rather than regenerating a one-off instruction stream each time.
5. Deployment Architecture: Putting the Agent in a Controllable Loop
To use code-execution agents reliably in real business settings, a layered closed loop is recommended:
- Perception layer: Uniformly obtain interface structure and data content, reading structured data rather than relying only on pixel recognition, to reduce ambiguity.
- Planning layer: Have the model produce “rules + function skeletons,” clarifying the target set and termination conditions rather than a fixed action list.
- Execution layer: Run generated code in an isolated environment, restrict filesystem and network access scope, and set timeouts and resource limits.
- Validation layer: Run completeness assertions, sampled manual-rule re-checks, and read-back of key states; on failure, fall back and re-plan.
- Observability layer: Use logging services and monitoring alerts to record the basis for each decision, input/output summaries, and failure reasons, ensuring reproducibility.
For cloud implementation, container platforms can host isolated execution, object storage can hold intermediate artifacts and result snapshots, message queues can decouple task distribution, and logging and monitoring systems can provide full-chain tracing. These are all general capability categories, not tied to any specific vendor implementation.
6. Risk Control and Governance Essentials
- Least privilege: Grant the execution account only the operations necessary to complete the task, and prefer rollback-capable methods for write operations.
- Idempotent design: Repeated execution produces no side effects; update operations decide whether to skip based on a status field.
- Sample-driven regression: Maintain a set of official or business samples as a regression suite, and run the regression before any prompt or rule change.
- Human gates: High-risk actions (deletion, bulk changes, external submission) require mandatory human confirmation or secondary approval.
- Cost constraints: Limit the maximum number of loop iterations and the duration per task to prevent resource runaway caused by logic defects.
7. Conclusion
The move from batch actions to code execution is, on the surface, a change in output format, but in essence a shift in the timing of decisions: handing uncertainty to runtime and trading judgment, loops, and validation for coverage and robustness. For developers, what truly needs to be built is not a “model that is better at clicking a mouse,” but an engineering system that makes model output executable, verifiable, rollback-capable, and observable. Whoever builds this closed loop first can push agents from demonstration to production.
