Skip to content

    Forward Deployed Engineer

    Patterns: Act Safely and at Scale

    Five AI design patterns for systems that act: tool calling with approval, workflow or agent, batch processing, a review queue and an AI gateway.

    By Published 10 min read

    • fde
    • solution-architect
    • patterns
    • agents
    • tool-calling
    Share

    This lesson is part of AI Solution Architect: Design Method and Patterns. Enroll for free, then sign in, to read it in full.

    What you'll learn: five patterns for systems that do more than answer (tool calling with approval, workflow versus agent, asynchronous batch processing, a human review queue and an AI gateway), and how to finish the project's pattern shortlist.

    At a glance

    Figure 1. The act patterns in phase 2 of the Order and Policy Assistant

    Act patterns in phase 2: approval, tool server, batch worker and model gatewayOrchestrator to Approval service (proposes action); Approval service to Tool server (approved, key); Tool server to Order system (writes); Orchestrator to Model gateway (calls model); Model gateway to LLM provider (sends text); Worker to Model gateway (batch jobs)Orchestrator: 8 workflow in codeOrchestrator8 workflow incodeApproval service: 10 review queueApprovalservice10 review queueTool server: 7 runs after approvalTool server7 runs afterapprovalOrder system: writes onceOrder systemwrites onceModel gateway: 11 AI gatewayModel gateway11 AI gatewayLLM provider: hostedLLM providerhostedWorker: 9 batch, off the pathWorker9 batch, off thepathproposes actionapproved, keywritescalls modelsends textbatch jobs

    How to read this: the model only proposes; a person approves; the Tool server makes the one write, with an idempotency key (a unique id that makes a repeat change nothing); model calls pass through one gateway to the LLM (large language model) provider.

    • A model proposes actions; code and a person decide whether they run.
    • Prefer a workflow of fixed steps; use an agent loop only when steps cannot be known in advance.
    • One AI gateway gives one place for keys, limits and logs.

    Scenario

    Composite scenario, not a real company. The first release of the Lumen Order and Policy Assistant, a fictional distributor's tool for its 24 customer-operations agents, is read-only. For phase 2 the Head of Customer Operations wants three actions: change a delivery address, apply a discount exception, create a return authorisation. Team leads approve exceptions up to their limit; only Finance releases a credit hold.

    What you will be able to do

    • Choose among the five act patterns for a requirement.
    • Put a human approval and an idempotency key in front of every write.
    • Explain why a workflow beats an agent when steps are known.

    Prerequisites

    Core ideas

    Pick a pattern from the requirement

    Figure 2. Which act pattern fits

    flowchart TD accTitle: Choosing an act pattern accDescr: First ask whether the task changes data in another system; if so use tool calling with approval. Otherwise, if no one waits for the answer, use batch processing. If someone waits and the steps are known, use a workflow; if not, use an agent with a step limit. Then ask whether some outputs need a person's judgment and add a review queue, and whether several features call models and add an AI gateway. A["A requirement"] --> B{"Changes data in another system?"} B -- yes --> T["Tool calling with approval"] B -- no --> C{"Does a user wait for the answer?"} C -- no --> BA["Asynchronous batch processing"] C -- yes --> D{"Steps known in advance?"} D -- yes --> W["Workflow in code"] D -- no --> AG["Agent with a step limit"] T --> H{"Some outputs need a person's judgment?"} BA --> H W --> H AG --> H H -- yes --> Q["Add a human review queue"] H -- no --> G{"Several features call models?"} Q --> G G -- yes --> GW["Add an AI gateway"] G -- no --> Z["Direct provider adapter"]

    How to read this: the first questions pick how the work runs; the last two add a review queue and a gateway.

    Who decides What can go wrong Control
    Tool calling with approval Model proposes, person approves Wrong or repeated write Exact arguments, idempotency key
    Workflow Your code Rigid for odd cases Tests per step
    Agent The model, in a loop Loops, cost, wrong tool Step limit, allow-list
    Batch A scheduler Late failures Retry, report
    Review queue A person Queue grows Owner, deadline
    AI gateway Policy in one place Single point of failure Redundancy, clean logs

    Pattern 7: Tool calling with approval

    • When to use: the system must change data elsewhere (an address, a discount) and a mistake costs money or trust.
    • When not to: the task only reads; fetch in code instead.
    • Structure: the Orchestrator, Approval service and Tool server path in Figure 1. The application runs the call (tool-use documentation).
    • Failure modes: invented arguments; approval of a summary, not the real arguments; a write sent twice; a tool with more access than the user.
    • How to evaluate: golden requests (fixed test requests with known right outcomes); tests that a bad argument or unauthorised tool is refused and that replaying a key writes once.
    • Cost profile: one extra model turn per call plus people's time.
    • Minimal build: one tool with a strict argument schema; code checks arguments and permission; a person approves the exact arguments; the write carries an idempotency key (approval gate, retries and keys).
    • Used in the Order and Policy Assistant: not in the read-only MVP (minimum viable product, the first release). Phase 2 uses it for address changes, discount exceptions and return authorisations.

    Pattern 8: Workflow versus agent

    • When to use a workflow: the steps are known, so code fixes the order. Anthropic's article describes workflows as orchestrated "through predefined code paths" (source).
    • When to use an agent: the next step depends on what the last found, and a step limit and tool allow-list can bound it. The article describes agents as models that "dynamically direct their own processes and tool usage".
    • Structure: the Orchestrator in Figure 1, as a fixed sequence of calls.
    • Failure modes: a workflow too rigid for odd cases; an agent that loops or picks the wrong tool.
    • How to evaluate: run both on the same golden set; compare success, steps, cost and latency; adopt the agent only if it clearly wins.
    • Cost profile: a workflow makes a predictable number of calls; an agent's count varies.
    • Minimal build: a workflow in plain code first (workflow or agent); a loop only for the step that needs it.
    • Used in the Order and Policy Assistant: a workflow, yes; an agent, no. Every step is known: extract, route, fetch, retrieve, explain.

    Pattern 9: Asynchronous batch processing

    • When to use: nobody is waiting, volume is high and the work can finish later (evaluation reruns, bulk classification).
    • When not to: an agent is waiting on the screen.
    • Structure: the Worker in Figure 1, calling the model gateway off the request path.
    • Failure modes: failures found hours later; one bad item stopping the run; duplicates after a retry.
    • How to evaluate: counts in and out; a status per item; a rerun of failures matches a clean run.
    • Cost profile: the gain is keeping slow work off the user's path; check your provider's published terms before assuming a price difference (cost economics).
    • Minimal build: a queue of items, a worker handling one at a time with an idempotency key, a status per item and a report.
    • Used in the Order and Policy Assistant: not on the agent's path. Design proposal, not in the brief: rerun the golden set nightly as a batch.

    Pattern 10: Human-in-the-loop review queue

    • When to use: some outputs need a person's judgment, a limit or a signature before they take effect.
    • When not to: code can verify the check, or nobody has the authority and time to review.
    • Structure: the Approval service in Figure 1.
    • Failure modes: a queue that grows until people click through; an approver shown a summary, not the action; no owner or record of the decision.
    • How to evaluate: time to decision, share approved unchanged, share rejected, a sample re-checked by a second person.
    • Cost profile: people's time dominates.
    • Minimal build: proposals showing the exact action, an owner per size, approve or reject with a reason, an audit record (review queues).
    • Used in the Order and Policy Assistant: phase 2. Design proposal: the queue holds discount exceptions above 5 percent and changes after picked, approved by a team lead, a director or the warehouse (P-DSC-03, P-ORD-04).

    Pattern 11: AI gateway

    • When to use: several features or teams call models and you want one place for keys, limits, logging and provider changes.
    • When not to: a single prototype with one call; a gateway is another service to run.
    • Structure: the Model gateway in Figure 1; "AI gateway" is this catalog's name for it. It is not the customer's API gateway, which authenticates agents.
    • Failure modes: a single point of failure; logs capturing personal data; a silent retry that hides a failure.
    • How to evaluate: failure tests with the provider down; a check that logs hold no customer personal data.
    • Cost profile: one more component to host and watch (gateway architecture).
    • Minimal build: one internal endpoint adding the key, a timeout, a retry limit and a request id, with logs free of customer personal data.
    • Used in the Order and Policy Assistant: yes: the design already reaches the hosted model through a model gateway.

    In the interview: "Would you build an agent for this?" A strong answer asks whether the steps are known, proposes a workflow first, names the evidence that would justify an agent and keeps writes behind approval.

    Worked example

    Assumptions: illustrative phase 2 requests under P-DSC-03 and P-ORD-04; the system proposes, a person approves. An address change while the order is confirmed or allocated needs only the agent's confirmation.

    Proposal Rule Who approves
    Discount of 4 percent Agent may offer up to 5 percent The agent confirms
    Discount of 8 percent Above 5 and up to 10 percent A team lead
    Discount of 15 percent Above 10 and up to 20 percent A director
    Discount of 25 percent Above 20 percent is not allowed No one: code rejects it before any queue
    Address change, order picked Needs warehouse approval The warehouse lead

    Spot the flaw. The approval screen shows the model's sentence, "Apply a small discount to order 48213", with an Approve button; the tool then runs with the model's arguments. What is wrong?

    Answer

    The approver approves a summary, not the action, and a second click could repeat the write. Show the exact arguments, bind the approval to them, allow one use and send an idempotency key.

    Decision exercise. A held order needs a next step: the assistant must find why it is held, check payment status and propose what to do. Only Finance releases a credit hold. Choose and justify:

    • (A) an agent with a "release hold" tool.
    • (B) a workflow that reads the hold reason and drafts a request to Finance in a review queue.
    • (C) no automation.
    Model answer

    Choose B. The steps are known and the release is Finance's, so the assistant drafts the request and a person decides. A hands a Finance-only action to a model; C saves no time.

    Practice task

    Complete your pattern shortlist (artifact 2): one row for each of the 11 patterns, with MVP, phase 2 or no; a one-line reason; how you would evaluate it. Then write three sentences on the trade-off of your riskiest choice.

    Decide first, then reveal.

    Act patterns: who approves (interactive when JavaScript is on)

    A customer asks for exactly 10 percent off. Who approves?

    • The agent
    • A team lead
    • A director
    Answer

    A team lead. A team lead approves above 5 and up to 10 percent. A director is needed only above 10.

    Order 48213 is `picked`. The customer wants a new delivery address. What does the assistant propose?

    • Queue it for warehouse approval
    • Apply it once the agent confirms
    • Refuse: picked orders can never change
    Answer

    Queue it for warehouse approval. After `picked`, an address change needs warehouse approval (P-ORD-04). Agent confirmation covers only `confirmed` and `allocated`.

    A new feature always does the same steps: fetch the last order, retrieve the policy, explain. What do you build?

    • An agent loop with a step limit
    • An agent with every tool on its allow-list
    • A workflow of fixed steps in code
    Answer

    A workflow of fixed steps in code. When steps are known, code fixes the order. An agent is for steps that cannot be known in advance.

    Exercise

    Write the approval rule for discount exceptions: what the approver sees, who approves each size, what happens at 25 percent and how a double click is stopped.

    Acceptance criteria: the rule uses the P-DSC-03 limits; the approver sees the exact order and percentage; code rejects more than 20 percent; a repeat of the same request changes nothing. Done when a developer could build the queue from your rule.

    Hint 1: who sees what

    List what the approver needs. Then decide who approves each size.

    Hint 2: the double click

    Give each proposal an idempotency key when it is created. The write carries it, so a second approval is recognised and does nothing.

    Common mistakes

    • Calling something an agent when fixed steps would do.
    • Approving a summary instead of the exact arguments.
    • Giving a tool broader access than the signed-in user.
    • A review queue with no owner.

    Knowledge check

    1. Why does the model only propose an action and not execute it?

    The model returns a call and your application runs it, so code can validate arguments, check permission and require approval first. The model never holds write authority.

    2. When is a workflow better than an agent?

    When steps are known: a workflow makes a predictable number of calls and is testable step by step. Choose an agent only if a workflow demonstrably fails on your golden set.

    3. Why bind an approval to the exact arguments and one use?

    Otherwise the approver may approve something different from what runs. Binding makes approval specific; the key makes a repeat harmless.

    4. Why is batch processing not used on the agents' request path?

    An agent is waiting on the screen and a batch finishes later. Batch suits work nobody waits for.

    5. How is an AI gateway different from the customer's API gateway?

    The API gateway authenticates agents at the service's edge. The AI gateway sits between your service and the model provider, adding keys, limits, retries and logs free of customer personal data.

    You can now

    • Add the completed pattern shortlist to your design pack.
    • Choose among the five act patterns for a requirement.
    • Design an approval step bound to exact arguments and one use.
    • Explain why the project uses a workflow, not an agent.

    Further reading

    • Building effective agents, which distinguishes workflows from agents and recommends the simplest solution possible.
    • Tool use with Claude, which explains that for client tools the model returns a call and your application runs it.

    Last verified: 2026-11-03

    Next

    Integrating AI With Customer Order and Policy Systems

    Enroll to keep reading

    Lesson 4 of 6 · AI Solution Architect: Design Method and Patterns

    Five AI design patterns for systems that act: tool calling with approval, workflow or agent, batch processing, a review queue and an AI gateway.

    In the rest of this lesson

    • Practice task
    • Exercise
    • Common mistakes
    • Knowledge check
    • You can now
    • Further reading

    Enrolling is free. It unlocks every lesson in AI Solution Architect: Design Method and Patterns, tracks your progress across devices and keeps your quiz scores. The newsletter is optional.

    Ask about this article

    Get answers grounded in this post. AI-generated — based on this article, and may be imperfect.

    Scaled AI Weekly

    Enjoyed this? Get more like it every Monday.

    Real architecture decisions, LLMOps patterns that survive production, and engineering leadership advice — from 12+ years of building at enterprise scale. Free. No spam. Unsubscribe anytime.

    Get new articles by email

    Free. We email a confirmation link first, and you can unsubscribe from any email.

    Join engineers building production AI systems

    Comments