An algorithm is a finite, deterministic sequence of steps that transforms inputs into outputs. In an agent context, it is the part of the loop the operator wrote down — the explicit procedure that converts an abstract goal into a ordered set of tool calls.
An algorithm is not a prompt. A prompt tells an agent what to do in natural language. An algorithm tells the agent which steps to take, in what order, and with what inputs. The distinction matters: a prompt can drift; a written algorithm can be audited, versioned, and reproduced.
Algorithm, heuristic, and policy
Three terms that get conflated:
- An algorithm is fully specified. Given the same inputs, it always produces the same outputs. It can be inspected step by step.
- A heuristic is a rule of thumb — a shortcut that works most of the time but is not guaranteed. "If the file is older than 30 days, archive it" is a heuristic, not an algorithm.
- A policy is a high-level decision rule that governs which algorithm to apply. "Use the reconciliation algorithm for bank accounts, and the audit heuristic for receipts" is a policy.
Agents operate at all three levels. The operator's job is to keep them separate.
Example
A daily newsletter publish algorithm:
1. Pull the latest content list from the source directory. 2. Run the build script with today's date as the argument. 3. If the build succeeds, commit the output to the deployment branch. 4. If the build fails, capture the error output and write it to a log file. 5. Send a status note to the operator with the result.
Each step is deterministic. The same inputs — today's content, a working build script — produce the same output: a deployed newsletter or a logged failure.
Related
For a full treatment of how algorithms relate to loops, tools, and the human/agent/robot triad, see Algorithms: The Recipes Agents Need.
See also: State Graph, Tool.