THE SHORT ANSWER

Design from GOAL → STEPS → DECISIONS → TOOLS → CHECKS → APPROVALS → STOPPING CONDITIONS. Keep exact rules in code, give the model only decisions that need interpretation, validate every tool boundary and define success, failure, escalation and budget before the loop runs.

Specify the final state

Replace ‘handle customer requests’ with an observable goal such as ‘prepare a supported answer for an agent to approve, or route the case to the correct queue.’ Define what must be true at completion, what remains outside scope and who owns the outcome.

  • Trigger: what starts the work?
  • Inputs: which sources are authoritative?
  • Acceptance: what makes the outcome usable?
  • Constraints: which policies, budgets and deadlines apply?
  • Consequence: what can go wrong, and who is affected?

Separate steps from decisions

Illustrative document-intake workflow
StageBest controlWhy
Check file type and sizeDeterministic codeThe rule is exact
Classify document purposeModel with allowed labelsLanguage varies
Extract required fieldsModel plus schema validationContent varies; output shape does not
Approve a high-value exceptionAuthorised personThe consequence needs accountability
Write status to systemTool with narrow permissionExecution should be explicit and auditable

Do not ask the model to rediscover a fixed business rule on every turn. Reserve model choice for ambiguity that cannot be captured reliably in code.

Design each tool boundary

For every tool, define allowed inputs, identity, read or write scope, side effects, timeouts and an interpretable result. Validate model-generated arguments before execution. Return errors as observations the controller can route, rather than letting the model assume success.

Place approvals before external communication, financial changes, permission changes and other consequential actions. An approval should show the proposed action and essential evidence, not ask a person to supervise an opaque loop.

Evidence & context: OpenAI Developers · NIST

Write the ending before the loop

  • Success: the final state is independently verified.
  • Retry: the error is temporary and another attempt is safe.
  • Repair: a bounded correction can resolve a validation failure.
  • Escalate: a person must supply information or judgment.
  • Fail: the task cannot continue safely.
  • Stop: time, attempts, cost or scope reached its limit.

Evidence & context: Anthropic

Sources & further reading

  1. Building effective agents

    Anthropic. A provider's engineering taxonomy of agents and workflows, not a universal industry definition. We use the conceptual distinction, not its changing product recommendations.

  2. Function calling

    OpenAI Developers. Official documentation for model-selected function calls. The application, not the model, executes custom functions and must validate arguments, permissions and results.

  3. Generative Artificial Intelligence Profile (NIST AI 600-1)

    NIST. Risk-management guidance, including confabulation. It does not establish a universal error rate.

Examples and exercises are illustrative unless attributed to a source. No independent expert review is claimed.

A correction, a counterexample or an experience worth sharing?

Join the conversation ↗