Envelope
Writing

How to design an AI workflow before you build it

July 2026 · 9 min read

Most multi-agent systems fail because they were assembled, not designed. Here's a step-by-step process for going from a workflow objective to a complete spec — agents, handoffs, gates, and model assignments — before writing a line of code.

Quick answer

Designing an AI workflow before you build it means deciding — before any code is written — which agents your system needs, what each one does, how they pass work to each other, what tools they can access, and where human approval is required. The output is a spec: a document that describes the full system. Design first, then build from the spec. Skipping the design step is the most common reason multi-agent systems fail.

Why design comes before build

The natural instinct when building a multi-agent system is to start with the parts you understand. You know what the first agent should do, so you build it. Then you add a second agent to handle the next step. Then a third. The system grows by accretion — each piece added on top of the last.

This is the stitching problem. When agents are assembled rather than designed, the connections between them are never properly specified. Handoffs are ambiguous. Ownership of edge cases is unclear. One agent's output format doesn't match what the next agent expects. The system works on the simple path and breaks on everything else.

The fix isn't a better model or a smarter prompt. It's doing the design before any of it is built.

A designed workflow starts with the whole system visible on paper — agents, roles, tools, handoffs, pipeline order, and gates — before anything is implemented. Problems that would have surfaced as bugs at 2am surface instead as gaps in the spec, where they're cheap to fix.

What a workflow design covers

A complete workflow design has six parts. Leave any of them out and the spec is incomplete.

Agents and roles — Who does what? Each agent needs a named role with a clear scope. "Research agent" is not a role. "Research agent that finds the three most recent funding announcements for a given company and returns structured JSON with amount, date, and source" is a role. Vague roles produce agents with overlapping responsibilities and no clear success condition.

Tools — What can each agent access? Tool access is a design decision, not a configuration afterthought. An agent with access to your CRM, your email, and your calendar can do things you didn't intend. Declaring tool access at design time forces you to think through what each agent actually needs — and what it shouldn't touch.

Reporting lines and handoffs — How does work move through the system? Which agent delegates to which? What does one agent's output look like, and is that what the next agent expects as input? Handoffs are where most multi-agent systems break. Designing them explicitly — and treating them as a contract between agents — prevents the ambiguity that causes downstream failures.

Pipeline structure — What runs in what order? Some steps can run concurrently (two research agents working in parallel on different data sources); others must run in sequence (scoring can't happen until research is complete). The pipeline structure is a design decision that affects both correctness and speed. See parallel vs. sequential agents for the tradeoffs.

Human gates — Where does a human need to approve before the pipeline continues? Not every workflow needs gates, but the ones that touch external systems, send communications, or make high-stakes decisions usually do. A gate designed in from the start is an explicit checkpoint with clear approve/reject paths. A gate added after the fact is a workaround.

Model assignments — Which model runs each agent? A classifier doesn't need the same model as a drafting agent. Assigning models at design time — matched to each role's actual requirements — is where you control cost and quality. See model routing for the framework.

Step-by-step: how to design a workflow

This is a practical process for going from a workflow objective to a complete spec.

Step 1: Write the objective in one sentence

Before anything else, write down what the workflow accomplishes. One sentence. "This workflow takes a list of company names, researches each one, scores them against our ICP, and delivers a qualified list with rep briefs."

If you can't write the objective in one sentence, you don't understand the scope yet. Don't start designing until you can.

Step 2: Identify the outputs

What does the completed workflow produce? A list of scored leads? A drafted email? A set of classified support tickets? Work backwards from the output — it tells you what the final agent needs to produce and what the agents before it need to set up.

Step 3: Map the steps

Working backwards from the output, list the steps required to produce it. Each step is a candidate agent. Be specific: "research the company" is not a step. "Pull the last three press mentions, most recent funding event, and headcount from LinkedIn for each company" is a step.

Don't worry yet about whether one agent should handle multiple steps. That decision comes later.

Step 4: Define agent boundaries

Group related steps into agents, following the single-responsibility principle: each agent should do one thing well. An agent with two distinct responsibilities is usually a design signal that it should be two agents with a handoff between them.

The exception is when coordination overhead outweighs the benefit of separation. If two steps are always performed together, on the same data, in quick succession, and neither step needs to be independently reusable, one agent is fine.

Step 5: Define handoffs

For each agent, write down:

  • What input it receives (from where, in what format)
  • What output it produces (in what format, to whom)

Do this for every agent. The handoff spec is the contract between agents. If agent A produces { company: string, revenue: number } and agent B expects { name: string, arr: number }, you have a mismatch that will cause a failure — and it's far better to catch it here than in a production run.

Step 6: Assign tools

For each agent, list the external services it needs to call. Be specific. "The research agent needs access to our LinkedIn API integration and Apollo." Review each list: does this agent really need this tool, or has it ended up on the list by default? Agents with minimal tool access are easier to reason about and more secure.

Step 7: Identify gates

Read through the pipeline and ask: where could this workflow take an action that's hard to reverse or that carries significant risk? Send an email, modify a database record, post to social media, initiate a financial transaction — these are gate candidates. Mark them explicitly. Define what the reviewer sees, what approve/reject does, and what happens on timeout.

Step 8: Assign models

For each agent, assign a model based on what its role demands. Classifiers and triage agents: fast, cheap models. Drafting and synthesis agents: stronger models. Orchestrators and judgment calls: frontier models. If you don't know the model yet, note the tier (fast / balanced / frontier) and finalise later. See model routing for the decision framework.

Common design mistakes

Too few agents, each doing too much. An agent with five responsibilities is an overloaded agent. Its prompt is long, its instructions are in tension with each other, and when something goes wrong it's impossible to tell which responsibility failed. More agents with narrower scopes are easier to build, debug, and improve.

Too many agents creating coordination overhead. The opposite problem. A pipeline with twelve agents that each do one trivial thing is expensive to orchestrate and fragile at every handoff. Group tightly related steps; don't split for the sake of atomicity.

No gates on high-stakes actions. An agent that sends emails without a gate is an agent that will eventually send the wrong email. Designing gates in from the start is almost always worth it for external actions.

Vague role definitions. "An agent that helps with research" is not a role. Vague roles produce agents that try to do everything and succeed at nothing. Every agent should have a role definition specific enough that you can evaluate whether a given output passes or fails.

Undefined handoff formats. Agents are designed in isolation and assumed to be compatible. The first production run reveals that the format mismatch is fatal. Write the handoff contract — input format, output format — before building either agent.

No clear objective. The hardest one to avoid. If you start designing before you've articulated the objective clearly, the design will drift. Every debate about scope becomes harder to resolve without a written objective to reference.

What the output looks like

A completed workflow design is a spec — a document (or structured file) that describes:

  • The workflow objective
  • Every agent: name, role, tools, model assignment
  • The reporting hierarchy: who delegates to whom
  • The pipeline: which steps depend on which
  • Every handoff: input format, output format, destination
  • Every gate: position in pipeline, gate type, trigger condition, rejection path

This is the document your engineering team builds from. It's also the document you review before anything is built — the place where gaps and conflicts are caught while they're still cheap to fix.

The spec doesn't need to be code. A well-structured document is enough. What matters is that it's complete enough that someone who wasn't in the design session can read it and understand what to build.

Where Envelope fits

Envelope is the tool for producing this spec from a natural-language description. You describe the workflow you want — in plain language, in a conversation — and Envelope structures it into a complete multi-agent design: named agents, roles, tools, model assignments, reporting lines, and gate configuration. The output is an exportable JSON spec that follows the open Envelope schema.

The design step is the whole product. Envelope doesn't run your agents — it designs them. The spec is the handoff artifact: structured enough for an IT team to implement, readable enough for a stakeholder to review and sign off on.

If you want to understand what the full design vocabulary looks like — agents, pipelines, gates, model routing — The anatomy of a multi-agent is the place to start.

Design your AI agents in Envelope

Envelope turns a plain-language description of your workflow into a complete AI agent system — agents with named roles, model assignments, tool access, handoffs, and human review gates. Free to start, no code required.

Start designing →

Frequently asked questions

Why should I design an AI workflow before building it?

Designing before building forces you to specify the parts of the system that are hardest to fix once built: agent boundaries, handoff formats, tool access, and where human approval is required. Problems caught at design time are cheap. Problems caught in production are expensive — mismatched handoff formats, overlapping agent responsibilities, and missing gate coverage are all design errors, and they compound the longer they go unaddressed.

What is the output of an AI workflow design?

A spec — a document that describes every agent in the system, its role, the tools it can access, the model it runs on, how it receives input and passes output to the next agent, and where human gates pause the pipeline for review. The spec is the handoff artifact for engineering teams and the review artifact for stakeholders.

How many agents should an AI workflow have?

Enough to give each agent a single clear responsibility, but no more. Overloaded agents (too few, doing too much) are hard to debug and produce inconsistent output. Over-split agents (too many, each doing almost nothing) create coordination overhead and fragile pipelines. The right number follows from the steps: one agent per distinct responsibility, grouped where tight coupling makes separation impractical.

What is a handoff in a multi-agent workflow?

A handoff is the boundary between two agents: what one agent outputs and what the next agent receives as input. Handoffs need to be designed explicitly — the output format of agent A must match the input format agent B expects. Undeclared handoffs are the most common source of multi-agent system failures, because mismatches only surface at runtime.

What is a human gate in a multi-agent workflow?

A human gate is a checkpoint in the pipeline where a human must approve or reject before the next step runs. Gates are designed in at specific points — typically before high-stakes or irreversible actions like sending emails, modifying records, or making purchases. A gate designed in from the start has a clear review interface, defined approval and rejection paths, and a configured timeout behaviour. A gate added after the fact is usually a workaround.

How do I know which model to assign to each agent?

Match the model to what the role demands. Classifiers and triage agents that make categorical decisions work well on fast, cheap models. Agents that draft text people will read, synthesise large amounts of context, or make complex judgment calls need stronger models. See model routing for a full decision framework and worked example.

Can I use Envelope to design a workflow without writing code?

Yes. Envelope takes a natural-language description of your workflow and produces a complete multi-agent spec — agents, roles, tools, model assignments, handoffs, and gates — with no code required. The output is a structured JSON file that an engineering team can implement. The design step in Envelope is what this article describes; the spec is the output.

Validate your workflow spec

Paste your agent spec into the validator to check structure, role clarity, and tool access before you build.