Specifying an AI agent means defining five bounded elements—goal, tools, constraints, failure modes, and escalation paths—instead of mapping every possible conversation branch. A flowchart tries to enumerate paths through a decision tree; an agent spec instead bounds a space of behavior the model can reason inside, which is the only approach that scales past a handful of scenarios.

Quick answer: Write a five-part spec—goal, tools, constraints, failure modes, escalation—and bound the agent's behavior instead of drawing every branch. If your refund-processing flowchart can't fit on one whiteboard, you don't need a bigger whiteboard. You need a spec.

Why a Flowchart Breaks the First Time a Customer Goes Off-Script

A flowchart works when the input space is small and the paths are known in advance, like a password-reset wizard with five predictable states. It breaks the moment an LLM-based agent faces open-ended language, ambiguous intent, or a customer who mixes two requests in one message—because no diagram can enumerate infinite phrasing.

The refund agent that ate a whiteboard

Imagine specifying a refund-processing agent the old way: a box for "customer requests refund," a diamond for "within return window?," branches for partial refunds, store credit, exchanges, fraud flags, loyalty-tier overrides, and international tax reversals. Each new edge case—a customer wanting a refund plus a price-match, or one already flagged twice for chargebacks—adds another diamond.

Real support conversations do not stay inside boxes. A customer might say "just give me store credit, I don't want to deal with a return label" halfway through a refund flow, or reference an order tied to a different account. A flowchart has to reject or route around anything it didn't anticipate; an agent spec lets the model handle it inside a bounded space.

This is the same distinction Anthropic draws in its widely read engineering guide on building effective agents: a workflow is orchestrated through predefined code paths, while an agent dynamically directs its own process and tool use within limits a human sets in advance. The practical implication for PMs is that you stop trying to predict every path and start defining the edges of acceptable behavior.

The stakes for getting this right are rising, not falling. METR's 2025 research on AI task horizons found that the length of tasks models can complete autonomously has been roughly doubling every few months—meaning the agents PMs are being asked to spec are taking on longer, less-scripted workflows faster than most teams' spec practices are maturing. Gartner, separately, has predicted that over 40% of agentic AI initiatives will be scrapped by 2027, citing unclear business value and inadequate risk controls as leading causes—a figure that tracks closely with how many teams skip straight from a prompt to a production agent without ever writing down a constraint.

Flowchart / WorkflowAgent Spec
Unit of designExplicit paths (if/then branches)Bounded space (goal + constraints)
Scales withNumber of scenarios anticipatedClarity of the boundary, not scenario count
Handles novel inputFails or defaults to "contact support"Reasons within the goal and constraints
Failure surfacesMissing branch, dead-end stateDrift, tool misuse, unbounded action
PM's jobEnumerate every pathDefine goal, tools, constraints, failure modes, escalation

That table is the crux of the shift. Once you accept that you cannot enumerate paths, the question becomes: what do you specify instead? That's where the five-part spec comes in.

It isn't just refunds

The same math applies anywhere an agent takes free-text input and multi-step action: a scheduling agent juggling conflicting calendar constraints, a coding agent modifying a shared codebase, an internal ops agent reconciling vendor invoices. Each of these has a "refund window" equivalent—a rule that seems simple until a real user combines it with two other rules at once.

The tell that you're looking at agent-shaped work, not workflow-shaped work, is this: if you can list every input variation your team has actually seen in support tickets or logs, and the list fits in a spreadsheet with fewer than twenty rows, you likely still have a workflow. Past that, you're bounding a space, not drawing a map.

The Five-Part Agent Spec: An Organizing Model for Bounded Autonomy

An agent spec has five required parts: a goal stating the outcome, a tool list stating the only actions available, constraints stating hard limits, failure modes naming what can go wrong, and an escalation path stating when to stop and hand off to a human. Miss any one and the agent either under-performs or takes an action nobody authorized.

Why five, not three or ten

Three fields—goal, tools, constraints—describe what the agent can do. That's necessary but not sufficient, because it only describes the happy path. Failure modes and escalation describe what happens when the agent is wrong, uncertain, or blocked, which for autonomous systems is not an edge case; it's a routine operating condition.

Consider each field applied to the refund agent:

Spec fieldRefund-agent example
GoalResolve refund requests within policy, minimizing manual review, without approving anything outside the return window unless flagged for review
ToolsLook up order, issue refund up to $150, issue store credit, flag for human review, message customer
ConstraintsNever refund above $150 unsupervised; never refund to a different payment method than the original; max one refund per order
Failure modesOrder not found, refund API timeout, customer disputes the agent's reading of policy, duplicate refund requested
EscalationAny refund over $150, any fraud-flagged account, any customer who explicitly asks for a manager

Each field constrains a different failure surface. A goal without constraints produces an agent that is technically "helpful" but finds loopholes. Tools without failure modes produce an agent that silently breaks when an API times out instead of retrying or escalating. We break down each field in more depth in our guide to the five-part agent spec structure, including how to write each one so an engineer can build against it without follow-up questions.

The spec is a contract, not a description

Treat the spec the way you'd treat an API contract: engineers should be able to build an eval suite directly from it, and support leads should be able to audit a transcript against it after the fact. If a field is vague enough that two readers disagree on what it means, it isn't done.

Does this change for multi-agent systems?

The framing holds even when the "agent" is really an orchestrator delegating to sub-agents—each sub-agent still needs its own goal, tool list, constraints, failure modes, and escalation path, and the orchestrator needs a sixth: rules for how sub-agent outputs get reconciled when they disagree. Don't skip the sub-agent specs because the orchestrator has one; that's the same mistake as writing one flowchart for a system that actually has five.

The Goal: One Sentence That Prevents Scope Drift

The goal is the single sentence that tells the agent what "done" and "good" look like; without it, an agent optimizes for whatever the training data or system prompt implies, which usually isn't what you meant. A well-written goal names the outcome, the boundary of authority, and the metric that matters, in that order.

Vague goals cause the drift you're trying to prevent

"Help customers with refunds" is not a goal—it's a job title. It gives the model no signal about when to stop being helpful. Compare it with: "Resolve refund requests that fall within the 30-day policy window without human review; route everything else to escalation." The second version bounds the space; the first invites the agent to interpret "help" expansively, which is exactly how agents end up approving refunds they shouldn't, or promising things support can't deliver.

This is the most common root cause of what teams call "agent drift"—the model doesn't malfunction, it optimizes correctly against an under-specified target. We go deep on the mechanics of this failure and how to word a goal so it resists reinterpretation in how to write an agent goal without drift.

A goal checklist

Before you hand a goal to engineering, it should pass three tests:

  1. Does it name a stopping condition? ("until resolved" versus "resolved or escalated, whichever comes first")
  2. Does it name what NOT to optimize for? (Don't optimize for conversation length or CSAT if that incentivizes over-promising.)
  3. Could a new hire read it and know what to do on a case you didn't anticipate?

If the answer to any of these is no, the goal needs another draft before it reaches a tool list.

Goals compound across a session, not just a single turn

A goal that reads well for a single exchange can still drift over a ten-turn conversation, because each turn's output becomes part of the next turn's context. Specify whether the goal applies per-message or per-session, and whether the agent should periodically re-check its own progress against the original request. Long sessions are where "helpful" quietly turns into "over-committed," and it rarely shows up in a one-turn test.

Tools: The Only Actions the Agent Is Allowed to Take

The tool list is the exhaustive set of actions an agent can invoke—API calls, database writes, messages sent—and anything not on the list is, by construction, impossible for the agent to do. Unlike a flowchart's branches, tools are not paths; they are capabilities, and each one needs its own permission boundary, not just a description of what it does.

Capability is not the same as permission

A common mistake is giving an agent a process_refund tool with no upper bound, assuming the constraints layer will catch bad calls. Constraints are a second line of defense, not a substitute for scoping the tool itself. If the tool can technically refund $10,000, a prompt-level instruction not to is one bad completion away from an incident.

This is where PMs coming from deterministic feature work need a mental-model shift. In a traditional feature, "give the button an onClick handler" and "constrain what the handler can do" are often the same conversation. In agentic systems, the tool's blast radius and the agent's judgment are separate design decisions, and both belong in the spec. Anthropic's and OpenAI's tool-use documentation converge on the same practice: keep each tool narrow, name it descriptively, and design its inputs and outputs so a model can reason about them without ambiguity—the tool interface is part of the spec, not an implementation detail you hand off and forget.

A tool inventory table

ToolWhat it doesUpper boundWho else can call it
lookup_orderReads order and customer historyRead-onlySupport agents, agent
issue_refundIssues a refund to the original payment method$150 per transactionSupport agents (higher limit)
issue_store_creditIssues non-refundable store credit$150 per transactionSupport agents (higher limit)
flag_for_reviewRoutes the case to a human queueN/AAgent only

Notice the last column: tool access is comparative, not absolute. A refund agent's $150 ceiling only makes sense next to what a human support rep is trusted to do on their own. If you don't know that number, you're guessing at the agent's boundary too.

Tool outputs need structure too

It's easy to spec the input side of a tool call and forget the output side. If lookup_order returns a loosely formatted string instead of a typed object, the agent has to interpret the result the same way it interprets a customer message—which reintroduces exactly the ambiguity you were trying to remove. Specify tool outputs as structured data with a fixed schema, the same discipline you'd expect from any internal API.

Constraints: The Guardrails That Replace Your Branches

Constraints are the hard limits that hold regardless of what the goal seems to justify—dollar caps, rate limits, prohibited combinations, required approvals—and they do the enumeration work a flowchart used to do, just expressed as rules instead of paths. Where a flowchart says "if X then go to node Y," a constraint says "never do Z, no matter how you got here."

Constraints are where tradeoffs get made explicit

Every constraint embeds a tradeoff: refund speed versus fraud exposure, autonomy versus oversight cost, customer goodwill versus policy consistency. Writing the constraint forces that tradeoff into the open instead of leaving it as a case-by-case judgment call an engineer makes at 11 p.m. during an incident.

If you haven't run a structured tradeoff exercise before writing constraints, do it first—vague constraints usually trace back to a tradeoff nobody actually resolved. Our tradeoff analysis complete guide walks through frameworks for making these calls explicitly rather than by default.

Categories of constraint worth specifying separately

  • Financial limits: transaction caps, cumulative daily caps, refund-to-original-method-only rules.
  • Rate limits: max actions per session, per customer, per hour, to contain a misbehaving loop.
  • Data boundaries: what the agent can read (order history) versus never touch (full payment card numbers, other customers' records).
  • Irreversibility flags: which tool calls can be undone and which can't—irreversible actions deserve tighter constraints or mandatory confirmation.
  • Policy exceptions: cases where the "right" answer conflicts with stated policy (a loyal customer, a goodwill gesture)—decide in advance whether the agent can make exceptions at all.

A constraint that only exists in a Slack thread from launch week isn't a constraint. It's institutional memory waiting to fail silently the moment the person who remembers it leaves.

Stress-test constraints before launch, not after

Once constraints are drafted, try to break them on purpose: feed the agent adversarial or contradictory requests and see whether it holds the line. This is standard practice in the risk-management guidance NIST publishes for generative AI systems, which recommends structured adversarial testing before deployment rather than relying on the base model's default behavior to hold under pressure. Treat every constraint the model talks its way around during testing as a spec bug, not a model bug.

Failure Modes: Planning for the Agent's Bad Days

A failure mode is a named, anticipated way the agent can go wrong—not a bug you fix later, but a condition you design a response for now, because autonomous systems fail routinely and quietly if nobody specified what "wrong" looks like. Naming failure modes up front is what separates a spec from a wish list.

The taxonomy PMs actually need

Failure modeExample (refund agent)Design response
Tool failureRefund API times out mid-callRetry once, then flag for review; never assume success
Hallucinated dataAgent cites a return-policy clause that doesn't existGround policy answers in a retrieved document, not model memory
Ambiguous inputCustomer wants "a refund" but has two open ordersAsk one clarifying question before acting
Loop or repetitionAgent re-issues the same refund after a retryIdempotency check before every write action
Policy conflictCustomer's case technically qualifies but "feels" like abuseEscalate rather than let the model use judgment on fraud calls
Silent driftTone or promises slowly diverge from brand voice over a long sessionSession-length caps, periodic re-grounding in the system prompt

Most teams new to agentic design catastrophize the wrong failures—worrying about the model saying something offensive—while underinvesting in the boring ones, like silent drift and tool timeouts, that actually cause incidents in production. The failure modes worth specifying are the ones a support lead would recognize immediately from a bad Tuesday, not the ones that make a good conference talk.

Because a failure mode is only useful if the customer-facing moment around it is designed too—what the agent says when it's wrong, how it hands off—see our UX of failure complete guide for how to design those moments instead of leaving them to whatever the model generates by default.

How many failure modes is enough?

There's no fixed number, but a useful heuristic: if your last three production incidents (or your best guess at likely ones) aren't each mapped to a named failure mode with a designed response, the spec isn't ready to ship. Retrofit failure modes from real incidents rather than inventing them from imagination alone.

Escalation: When the Agent Should Stop and Ask a Human

Escalation is the explicit rule set for when the agent must stop acting and hand control to a person, and it's the field most often left implicit—which is exactly why under-specified agents either escalate everything (annoying) or nothing (dangerous). A good escalation path names the trigger, the destination, and what context travels with the handoff.

Escalation triggers, ranked by how often they're missed

  1. Confidence-based: the model's own uncertainty crosses a threshold (hardest to spec well; treat as a supplement to explicit rules, not a replacement).
  2. Value-based: the transaction, refund, or decision exceeds a dollar or risk threshold.
  3. Repetition-based: the same customer or case has looped through the agent more than once without resolution.
  4. Sentiment-based: detected frustration, an explicit request for a human, or legal/compliance language.
  5. Novelty-based: the case doesn't match any known category in the spec at all.

Teams frequently spec #2 and forget #3 and #5—which is how an agent ends up in a five-message loop reassuring an increasingly frustrated customer instead of recognizing it's stuck. Novelty-based escalation is worth calling out specifically: it's the safety net for every scenario your discovery work didn't surface, and a spec without one implicitly assumes discovery was complete, which it never is.

What travels with the handoff matters as much as the trigger

An escalation that dumps a raw transcript on a human without a summary, the customer's stated goal, and what the agent already tried is barely better than no escalation at all—the human still has to reconstruct context under time pressure. Specify the handoff payload with the same rigor as the trigger:

Handoff elementWhy it matters
One-line case summaryHuman doesn't re-read the full transcript to get oriented
What the agent already triedPrevents the human from repeating a failed action
The specific trigger that caused escalationTells the human what kind of judgment is needed
Customer's stated goal, in their wordsKeeps the human from re-litigating the request from scratch

From Spec to Shipped: Testing, Discovery, and Where Prodinja Fits

A spec is only as good as the evidence behind it, which means writing one is a discovery exercise, not a documentation exercise—you're encoding real decisions about real failure patterns, tradeoffs, and customer language, not filling in a template. Validate the spec against actual conversations before an engineer builds against it, the same way you'd validate any other product requirement.

Ground the spec in discovery, not assumption

Pull real transcripts, support tickets, or session recordings for the workflow you're agentifying before you write goal or constraint language. If you're specifying a refund agent, read fifty real refund conversations first; the failure modes and escalation triggers you find there are more reliable than any brainstorm. Our product discovery complete guide covers how to run that kind of evidence-gathering efficiently instead of skipping straight to requirements.

It also helps to have a working sense of what the underlying model can and can't reliably do—context-window limits, why hallucination rates rise with ambiguous grounding, what "temperature" actually changes about output determinism—before you promise a constraint the model architecture can't enforce. Our LLM fundamentals complete guide covers the concepts worth knowing before you write any agent spec, not just this one.

Turn the spec into evals, not just documentation

Once the five fields are drafted, each failure mode and constraint should become a test case: a scripted conversation that checks whether the agent actually retries on timeout, actually refuses the over-limit refund, actually escalates on the sentiment trigger. This is the same logic behind the ReAct-style reasoning-and-acting loop that much of modern tool-using agent design descends from—verify the loop's behavior at each step, not just its final answer. A spec nobody has tested against real or synthetic transcripts is still a hypothesis.

Where Prodinja fits

This is the exact gap Prodinja's Agentic Workflows tool is designed to close: instead of a blank document, it walks you through speccing a bounded agent field by field—goal, tools, constraints, failure modes, escalation—and its deterministic checklist flags any of the five that's missing before you hand the spec to an engineer. It doesn't judge whether your goal is good; it makes sure you didn't skip writing one, which turns out to be most of the failures worth preventing.

A pre-flight checklist before you hand off the spec

  • Goal states an outcome, a boundary, and a stopping condition
  • Every tool has a named upper bound and a "who else can call this" answer
  • Constraints are written as rules, not vibes ("never," "always," not "usually")
  • At least the top three real-world failure modes are named with a designed response
  • Escalation triggers cover value, repetition, sentiment, and novelty—not just confidence
  • A person who's never seen the project could read the spec and know what "wrong" looks like

Key Takeaways

  • A flowchart enumerates paths; an agent spec bounds a space of behavior—that distinction is the entire reason agentic design needs a new artifact, not a bigger diagram.
  • The five required fields are goal, tools, constraints, failure modes, and escalation; skipping any one leaves a gap the model will eventually find and exploit or stall on.
  • Write the goal with a stopping condition and an explicit non-goal, or the agent will optimize for whatever "helpful" implies by default.
  • Treat tools as capabilities with their own blast radius, not just descriptions—permission and capability are separate design decisions.
  • Constraints are where implicit tradeoffs (speed versus fraud exposure, autonomy versus oversight) get made explicit; vague constraints usually trace back to an unresolved tradeoff.
  • Failure modes and escalation are routine operating conditions for autonomous systems, not edge cases—spec them from real incidents, not imagination.
  • Validate specs against real transcripts before engineering builds against them; a spec is a discovery output, not a documentation exercise.

Frequently Asked Questions

How do I know if I need an agent spec instead of a flowchart?

You need an agent spec once the input space includes open-ended language, ambiguous intent, or more scenarios than you can enumerate on one whiteboard in a single sitting. If your process has fewer than a dozen fixed states and no free-text input, a flowchart or a rules engine may genuinely be the simpler, better answer—don't reach for an agent spec by default.

What's the difference between a constraint and a failure mode?

A constraint is a hard limit the agent must never cross regardless of context (a dollar cap, a data boundary); a failure mode is an anticipated way the agent can go wrong despite following its constraints (a timed-out API, ambiguous input, hallucinated data). Constraints prevent bad actions; failure modes prepare for bad conditions.

Who should write the agent spec—the PM, the engineer, or both?

The PM typically owns the goal, constraints, and escalation logic since those encode business and customer tradeoffs; engineering typically owns tool implementation and failure-mode detection mechanics. Both should co-review the full spec before build, because a goal an engineer can't build against and a tool boundary a PM didn't sanity-check cause the same downstream incident.

How detailed should failure modes be before an agent ships?

At minimum, the failure modes behind your last three real (or realistically anticipated) production incidents for that workflow should each have a named trigger and a designed response—not a promise to "handle it gracefully." Anything vaguer than that usually means the failure mode was acknowledged, not actually thought through.

Can an agent spec replace user stories entirely?

No—an agent spec complements user stories rather than replacing them; the user story still frames the customer outcome, while the agent spec bounds how autonomously the system is allowed to pursue it. Teams that skip user stories and jump straight to a tool list tend to build agents that are technically bounded but solve the wrong problem well.