AI agents · OpenClaw · self-hosting · automation

Quick Answer

How AI Agents Work Compared to Traditional Automation Scripts

Published:

The short answer

A script executes a plan someone wrote; an agent writes its plan as it goes. In a traditional automation script, every branch is coded in advance — if this field is empty, then send that email. An AI agent receives a goal, a list of tools it may call, and instructions; a language model picks the next action, observes the result and loops until the goal is met or a stop condition fires.

That one difference drives everything else:

Traditional scriptAI agent
Who decides the next stepThe programmer, ahead of timeThe model, at run time
Input it handlesStructured, expected formatsUnstructured text, documents, ambiguous requests
Same input, same result?Yes (deterministic)Not guaranteed
Failure modeStops with an error on the unexpectedImprovises — sometimes correctly, sometimes wrongly
Cost per runCompute only, near zeroModel tokens on every step
SpeedMilliseconds to secondsSeconds to minutes (or hours for long tasks)
AuditingRead the codeLog and review every tool call
Change processEdit and redeploy codeChange instructions, tools or model

How an agent actually works

  1. Goal and context. The run starts with a task (“refund this order if it qualifies”) plus instructions and any relevant data.
  2. Reason. The model reads everything in its context and decides what to do next.
  3. Act through a tool. It emits a structured tool call — query a database, call an API, run code, search documents. Tools are ordinary functions; the Model Context Protocol (MCP) is the common open standard for exposing them to agents.
  4. Observe. The tool’s result is appended to the context.
  5. Loop or stop. Steps 2–4 repeat until the model returns a final answer or a guard (maximum steps, spend cap, required human approval) stops it.
  6. Memory (optional). Facts worth keeping are written to a store and loaded into later runs.

OpenAI’s guide to building agents describes the same three parts — model, tools, instructions — and Anthropic’s guidance draws the line that matters for design: workflows run LLMs through predefined code paths; agents let the model direct its own process.

A worked example: invoice exceptions

Script version: read each invoice from the accounts-payable API, match PO number and amount against the ERP, approve if both match, otherwise put it in an exception queue. Fast, cheap, correct — and every mismatch lands on a person.

Agent version, for the exception queue only: for each mismatched invoice, the agent reads the PDF, searches email for the vendor’s change notice, checks the contract terms, and either proposes an approval with its evidence or drafts a query to the vendor. A person approves the proposal.

The script still handles the 90% path. The agent replaces only the judgement a human used to do — the pattern that works best in practice.

When to choose which

Choose a script when:

  • the steps are known and stable;
  • inputs are structured;
  • the output must be identical every time (finance, compliance, data pipelines);
  • the job runs at very high volume where per-step model fees add up.

Choose an agent when:

  • inputs are free text, documents or conversations;
  • the right next step depends on what the last step found;
  • the alternative is a person reading and deciding;
  • some variation in the path is acceptable as long as the result is checked.

Choose both — a deterministic workflow with an agent at one step — when you can isolate the judgement. This is where most reliable production systems end up.

Guardrails a script never needed

  1. Least-privilege tools: give the agent only the tools and scopes the task needs — see how to lock down AI agent network egress.
  2. Human approval for irreversible actions (payments, deletions, outbound email).
  3. Step, time and spend limits on every run.
  4. Trace every tool call and evaluate a sample of runs — see how to monitor and evaluate AI agents in production.

For tools that mix fixed workflows and AI steps, compare n8n vs Zapier vs Make.

Last verified: October 12, 2026.

Sources