01Use agents for uncertain paths
If a fixed DAG can express the workflow, use it: it is cheaper, easier to test, and more predictable. Use an agent when new observations change the next action and semantic judgment is central.
The useful agent distinction is control flow. In a workflow, the application knows the sequence of steps; a model may classify or extract inside one step. In an agent loop, the model chooses a next action from observations within a bounded goal. A fixed refund policy often belongs in a workflow. Investigating an unfamiliar repository may require adaptive search and inspection.
Compare both designs before choosing. A workflow has explicit transitions that are easier to test and recover. An adaptive loop can explore uncertain paths but introduces variable step count, cost, and failure. Give it the smallest tool set and task scope that permits useful exploration. A hybrid can keep a deterministic outer workflow while delegating one uncertain subproblem to a bounded loop.
- Keep deterministic outer orchestration
- Define completion evidence
- Give the model the smallest useful action space
02State outlives context
Persist task state, tool results, artifacts, approvals, and checkpoints outside the prompt. Summarize or retrieve relevant history into context. A worker crash should not erase the run.
Persist the state needed to recover: run ID, original input, goal, policy versions, completed steps, tool attempts, approvals, and authoritative effects. The conversation is working context, not an adequate transaction log. A summarized conversation can omit the very detail needed to tell whether a side effect already happened.
Place checkpoints around effect boundaries. A worker may stop after a provider committed but before a local completion record was written. On restart, reconcile the operation using its stable identity; do not simply replay the last model instruction. Distinguish an unfinished read, an uncertain write, and a completed effect whose explanation was never delivered. Each resumes differently.
- Use explicit state machines for lifecycle
- Commit checkpoints after durable effects
- Separate user memory from task scratch state
03Every loop needs a budget and stop rule
Limit wall time, tokens, cost, calls, repeated actions, and privileges. Detect non-progress, oscillation, and duplicate calls. Escalate to a human or return a partial result with evidence.
Bound steps, wall-clock time, spend, tokens, and tool concurrency. A run can stay under a step limit yet spend too long in one tool or consume excessive output. Also detect non-progress: repeated equivalent calls, unchanged evidence, or the same error cycle. Budget exhaustion should produce a clear terminal or paused state with useful partial artifacts.
Define success using external evidence. A research task needs cited support; a coding task needs an inspectable patch and meaningful verification; a booking task needs a durable receipt. “The model says done” is not enough. Stop when the completion evidence is met, when an unrecoverable condition appears, or when budget is exhausted, and make those reasons visible to the caller.
- Approval pauses are durable states
- Replanning follows changed observations
- Multiple agents add coordination and context cost