AI ENGINEERING | LIVING GLOSSARY | #014
WORKFLOWS
Orchestrating Multi-Step AI Processes
Chapter 3: Connecting AI to Tools, Workflows, and Agents
Lesson 14 of 24
AIYING — Accomplishing with AI
A customer contacts an online retailer:
An AI assistant might understand the request. It might even have access to a refund-processing tool.
But should it immediately issue the refund?
Not necessarily.
The retailer may need to verify the customer's identity, retrieve the original order, confirm the returned item was received, check the applicable policy, determine eligibility, calculate the refundable amount, obtain approval when required, issue the refund through an authorized payment service, and communicate the outcome.
These are connected steps with dependencies, decision points, and potential failures.
The engineering challenge is no longer just calling a tool. It is coordinating the complete process.
That is the purpose of a workflow.
1. What Is an AI Workflow?
An AI workflow is a designed sequence or network of operations that coordinates AI model interactions, software tools, business rules, data, and sometimes human decisions to accomplish a defined task or outcome.
Not every step must involve AI.
A workflow may combine:
- Deterministic software operations.
- Language model calls.
- External API calls.
- Data retrieval.
- Conditional branching.
- Parallel tasks.
- Human review or approval.
- State persistence.
- Error handling and recovery.
For example, an invoice-processing workflow might extract information from a document using AI, validate totals using conventional software, check supplier records through an API, and route exceptions to a finance officer.
Important distinction: A workflow is not necessarily autonomous. Its sequence and decision boundaries can be explicitly designed and controlled by engineers.
↑ Back to contents2. Why Workflows Matter
Many business tasks cannot be completed reliably through a single prompt or tool call.
They require several coordinated operations.
| Single AI interaction | Engineered workflow |
|---|---|
| Produces one response. | Coordinates a complete process. |
| May operate on limited information. | Can retrieve and validate required information. |
| May not track progress across stages. | Can maintain explicit process state. |
| May leave execution details implicit. | Defines execution responsibilities and transitions. |
| May be difficult to recover after failure. | Can include checkpoints, retries, and recovery paths. |
| Often measures response quality. | Can measure end-to-end task outcomes. |
Workflows make it possible to engineer repeatability, accountability, and operational control around AI capabilities.
They do not guarantee reliability automatically. Reliability depends on workflow design, implementation, testing, and monitoring.
↑ Back to contents3. Common AI Workflow Patterns
A. Sequential workflow
Each step runs after the previous step completes.
Input → Retrieve → Analyze → Draft → Validate → Output
Useful when later operations depend on earlier results.
B. Conditional workflow
The process follows different paths based on explicit conditions.
Check Eligibility
|
v
Eligible?
/ \
Yes No
| |
Refund Explain
Review Rejection
C. Parallel workflow
Independent operations execute concurrently, followed by synchronization.
Request
/ | \
v v v
Check Check Check
Order Policy Payment
\ | /
v v v
Combine Results
Parallelism can reduce latency but introduces coordination and partial-failure challenges.
D. Human approval workflow
A designated person reviews or authorizes a consequential step.
AI Assessment
|
v
Human Approval
/ \
Approve Reject
| |
Execute Stop
E. Iterative workflow
A result is evaluated and revised until a defined stopping condition is met.
Generate → Evaluate → Revise
| |
+---------+
Stop when criteria
or limits are met
Iterations require explicit limits on time, cost, and attempts.
F. Event-driven workflow
A business event triggers a process.
Examples include a returned shipment arriving, a new support ticket being created, or a document being uploaded.
↑ Back to contents4. How an AI Workflow Works
A typical workflow moves through a set of states and operations.
Business Request / Trigger
|
v
Identify Workflow and Inputs
|
v
Validate Request and Identity
|
v
Retrieve Required Information
|
v
AI Analysis (where useful)
|
v
Business Rules and Checks
|
v
Decision / Approval Gate
|
v
Authorized Tool Execution
|
v
Verify Actual Outcome
|
v
Update State and Records
|
v
Notify User / Complete
The workflow controller determines which step runs next.
Some decisions can be made by deterministic rules. Others may involve model-generated classifications or recommendations.
Consequential actions should not rely solely on unverified model output.
In a production application, execution status should be tracked independently of the model's conversational response.
↑ Back to contents5. Workflows vs Tool Calling and Agents
| Concept | Main responsibility | Example |
|---|---|---|
| Tool Calling | Request an external capability. | Retrieve an order record. |
| Workflow | Coordinate multiple operations and transitions. | Verify a return, assess eligibility, approve and refund. |
| AI Agent | Use model-guided decisions to pursue a goal, often with tools. | Investigate a customer issue and select permitted next steps. |
| Orchestrator | Manage execution, dependencies, and state. | Schedule the next workflow step after approval. |
These categories are related rather than mutually exclusive.
An agent can operate within a workflow. A workflow can invoke agents. Both can use tool calling.
Engineering distinction: In a tightly controlled workflow, the developer specifies the main process structure. In a more agentic design, a model may have greater discretion over how to pursue a goal.
The appropriate choice depends on task uncertainty, risk, auditability, and required flexibility.
↑ Back to contents6. Workflow Architecture
A production workflow typically requires more than a sequence of prompts.
1. Trigger layer
Receives a request, event, or scheduled instruction.
2. Orchestration layer
Determines which operations run, in what order, and under what conditions.
3. AI processing layer
Performs tasks such as classification, extraction, summarization, or language generation.
4. Tool integration layer
Connects to external APIs, databases, and enterprise services.
5. Business rules layer
Applies deterministic constraints, eligibility rules, and operational policies.
6. Human oversight layer
Routes designated cases to authorized reviewers.
7. State and persistence layer
Records progress, intermediate results, approvals, and execution outcomes.
8. Observability layer
Captures traces, errors, timing, and relevant quality indicators.
7. Reliability, State, and Recovery
Real workflows encounter failures.
External APIs time out. Model outputs fail validation. Human reviewers become unavailable. Systems may restart midway through a process.
Reliable workflow design must anticipate these situations.
State management
Track states such as RECEIVED, VALIDATING, AWAITING_APPROVAL, PROCESSING, COMPLETED, and FAILED.
Retries
Retry transient failures only when safe. Use bounded attempts and appropriate delays.
Idempotency
Prevent duplicate effects when an operation is repeated, especially for refunds, payments, and ticket creation.
Timeouts
Define how long a step may run and what happens when it exceeds that limit.
Compensation
Where possible, design compensating actions for completed steps that cannot simply be rolled back.
Human escalation
Route uncertain, high-risk, or repeatedly failing cases to an authorized person.
Auditability
Record important decisions, approvals, and outcomes using appropriate access controls and retention policies.
End-to-end verification
Verify that the business outcome occurred, not merely that a model or API reported an intermediate success.
Important: A refund API timeout does not prove that the refund failed. The application may need to query transaction status before attempting the operation again.
↑ Back to contents8. Industry Applications
| Industry | Example AI workflow |
|---|---|
| Retail | Return verification, refund eligibility, approval, payment, notification. |
| Banking | Document intake, data extraction, validation, risk checks, human decision. |
| Healthcare administration | Document intake, classification, verification, and authorized routing. |
| Human resources | Employee request, policy lookup, approval, record update. |
| Software engineering | Requirement analysis, code generation, tests, review, deployment gate. |
| Supply chain | Inventory monitoring, exception detection, replenishment recommendation. |
| Customer support | Issue classification, account lookup, resolution, escalation, closure. |
| Knowledge management | Document ingestion, extraction, indexing, review, publication. |
Workflows are especially useful when tasks have dependencies, approvals, measurable outcomes, or operational consequences.
↑ Back to contents9. Engineering Design Decisions
Before building an AI workflow, an engineer should answer:
- What is the precise business outcome?
- What triggers the workflow?
- Which steps are deterministic?
- Which steps genuinely benefit from AI?
- What data and tools are required?
- What are the dependencies between steps?
- Which operations can run in parallel?
- What states must be persisted?
- Which actions require authorization or human approval?
- How will errors, retries, and timeouts be handled?
- How will duplicate operations be prevented?
- What is the maximum acceptable cost and latency?
- How will sensitive data be protected?
- How will completion be verified?
- What evaluation evidence demonstrates reliability?
The goal is not to insert AI into every step. It is to design the simplest process that reliably accomplishes the intended task.
↑ Back to contents10. Practical Industry Case: The Refund That Needed a Workflow
Scenario: A customer requests a refund for returned headphones.
Assume a fictional retail company with a policy requiring confirmation of receipt, eligibility checks, and approval for specified exceptions.
Workflow design
- Receive request: Record the refund request and create a workflow identifier.
- Authenticate: Verify the customer and access permissions.
- Retrieve order: Query the order management system.
- Check return: Confirm the item was received and inspected.
- Retrieve policy: Obtain the applicable refund rules.
- Assess eligibility: Apply business rules; use AI for interpretation only where appropriate.
- Handle exceptions: Route uncertain cases to an authorized reviewer.
- Calculate amount: Use validated transaction and policy data.
- Request approval: Apply any required authorization gate.
- Initiate refund: Invoke the payment service with an idempotency key.
- Verify transaction: Confirm the payment service's authoritative status.
- Update records: Record the verified outcome.
- Notify customer: Communicate the actual refund status.
- Close workflow: Mark completion only after required checks succeed.
Failure scenario A: Missing return confirmation
The workflow pauses or requests additional information rather than issuing an unsupported refund.
Failure scenario B: Policy exception
The workflow routes the case to a human reviewer with the relevant evidence.
Failure scenario C: Payment service timeout
The workflow checks transaction status before deciding whether a retry is safe.
Failure scenario D: Customer notification fails
The workflow records the refund outcome separately from notification delivery and retries or escalates the notification step.
What this case teaches
A successful AI workflow is not defined by the number of model calls it makes.
It is defined by whether it coordinates the right operations, enforces the necessary controls, and produces a verified business outcome.
11. Hands-On Mini Project
Build a Simulated AI Refund Workflow
Objective: Design and test a multi-step AI workflow using fictional orders and refunds. No real payments or customer accounts are required.
Step 1: Define the workflow
Create a flowchart showing intake, validation, retrieval, eligibility, approval, execution, verification, and notification.
Step 2: Create sample data
Prepare five fictional refund requests:
- Eligible return with confirmed receipt.
- Return outside the permitted window.
- Missing return confirmation.
- Refund requiring manager approval.
- Previously refunded order.
Step 3: Assign responsibilities
Mark each operation as one of:
- AI model task.
- Deterministic rule.
- External tool or API.
- Human decision.
Step 4: Define workflow states
Use states such as RECEIVED, VALIDATED, AWAITING_APPROVAL, REFUND_PENDING, COMPLETED, and FAILED.
Step 5: Simulate execution
Run all five requests through the workflow and record each transition.
Step 6: Inject failures
Simulate a timeout, invalid AI output, missing data, and duplicate refund request.
Step 7: Evaluate results
| Metric | What to measure |
|---|---|
| Completion rate | Percentage of valid requests reaching a verified final state. |
| Routing accuracy | Correct selection of eligibility, exception, and approval paths. |
| Unauthorized execution count | Actions executed without required permissions or approvals. |
| Duplicate refund count | Repeated payment effects for the same request. |
| Recovery success | Ability to resume or safely resolve interrupted workflows. |
| End-to-end latency | Time from request to verified outcome. |
| State accuracy | Whether recorded states match actual operations. |
Success criteria
- Every test request follows an appropriate path.
- No unauthorized refund is executed.
- No duplicate refund is issued.
- Missing information leads to a controlled pause or escalation.
- Failed steps do not falsely mark the workflow complete.
- Final status reflects the verified outcome.
Reflection
Which steps genuinely required AI? Which were better handled by conventional software? What would you change before production deployment?
12. Connected Glossary Terms
- Tool Calling (#013): Provides individual external capabilities used by workflows.
- Prompt Engineering (#006): Shapes model behavior within workflow steps.
- RAG (#004): Supplies retrieved information for particular workflow operations.
- Context Window (#005): Limits the information available to each model call.
- Evals (#007): Tests both individual steps and end-to-end outcomes.
- Hallucination (#008): Must be detected and controlled when model outputs influence decisions.
- Grounding (#009): Connects model responses to verified source information.
- Guardrails (#010): Enforces restrictions at workflow boundaries.
- Observability (#011): Supports tracing, monitoring, and diagnosis.
- Human-in-the-Loop (#012): Introduces review and approval gates.
Previous lesson: #013 — Tool Calling: Connecting AI Models to External Capabilities
Next lesson: #015 — AI Agents: Goal-Directed Systems That Use Tools and Make Decisions.
↑ Back to contents13. Living Update
Editorial baseline: November 2026
AI workflow engineering continues to evolve as organizations connect models with operational systems.
Areas to monitor include:
- Durable execution and workflow resumption.
- Integration of model calls with deterministic orchestration.
- Structured outputs and schema validation.
- Human approval and intervention mechanisms.
- Multi-agent workflow coordination.
- Workflow tracing and evaluation.
- Security boundaries for tools and data.
- Cost, latency, and reliability optimization.
- Standards and interoperability for tool integration.
Living Glossary note: Revisit this entry as orchestration technologies, agent frameworks, and enterprise operational practices evolve.
↑ Back to contents14. Key Takeaway
The value of an AI workflow lies not in its complexity, but in its ability to reliably achieve a meaningful business outcome.
Think like an AI engineer: If the process fails halfway through, can your system determine what already happened, what remains to be done, and how to recover safely?
↑ Back to contents15. References and Further Reading
- Temporal — Durable Execution and Workflow Documentation
- LangGraph — Workflow and Agent Orchestration
- OpenAI — Function Calling
- OpenTelemetry — Observability Documentation
- OWASP — Generative AI Security Project
- NIST — AI Risk Management Framework

