What you need to know
Most failed agent projects did not need an agent. Start with the simplest design that meets the requirement and add autonomy only when the task demands it.
Workflow or agent
| Workflow | Agent | |
|---|---|---|
| Who decides the steps | Your code | The model, in a loop |
| Fits when | The path is known in advance | The next step depends on what earlier steps found |
| Strengths | Predictable, cheap, easy to audit | Handles open-ended investigation |
| Costs | Rigid | More tokens, more variance, harder to test |
Common workflow patterns: prompt chaining (fixed sequence), routing (classify, then send to a specialized path), parallelization (independent checks at once, combined in code), orchestrator-workers (a lead model splits a task and delegates) and evaluator-optimizer (one call drafts, another critiques).
Most real systems mix both: route the predictable majority (say, address changes) into a workflow and send the unpredictable minority (disputes) to an agent.
Orchestrator and subagents
An orchestrator splits a task and sends parts to subagents, each with its own context window. This pays off when parts are independent and context-heavy (research across several sources, auditing several services).
- Give each subagent a distinct scope and a defined result format, so results do not overlap and stay small.
- Make every result carry a status. A missing or failed result is a gap, never "clean."
- Keep tightly dependent steps (reproduce, diagnose, fix) in one context. Splitting them loses detail at every handoff.
Where the agent runs
| Self-hosted harness (Agent SDK) | Managed runtime (Claude Managed Agents) |
|---|---|
| You run the loop on your infrastructure | Anthropic hosts the loop and a sandboxed container |
| Full control of network, images, logging | Persistent sessions you resume by ID, event streams |
| You build durability, sandboxing and scaling | No container infrastructure to operate |
| Fits strict "runs inside our network" policies | Fits teams that need sandboxed code execution without platform engineers |
The binding constraint decides. A bank that requires execution inside its own network chooses a self-hosted harness; a small team that needs long, resumable, sandboxed sessions chooses the managed runtime.
Hard rules stay in code
Even inside an agent, approvals over a threshold, validation of bookings or refunds, and audit logs belong in the harness or tools, not in the prompt. The model chooses what to try; the code decides what is allowed.
In the exam
Items describe requirements (predictability, error cost, audit, latency, hosting policy) and ask for the architecture or runtime. Pick the simplest design that meets them, keep hard rules in code, and match the runtime to the binding constraint. Distractors add agents or subagents for fixed paths, split dependent steps, trust model-written explanations as audit, or pick a runtime that breaks a stated policy.
Check your understanding
Every product listing goes through the same three steps in the same order. Which design fits?
Show answer
Answer: B. The path is known in advance, so code should sequence it.
Two subagents edited the same file in conflicting ways, and a third returned 40 pages of notes. What fixes both?
Show answer
Answer: D. Clear boundaries prevent conflicts; a compact result protects the orchestrator's context.
Policy requires agent code execution inside the company network, with its own images and logging. Where should the agent run?
Show answer
Answer: A. The hosting policy is the binding constraint, so the team keeps control of the environment.
Apply it: Design Juniper's support architecture
Juniper's order-support agent handles order lookups, returns, refunds and product questions. Refunds over $250 need a supervisor, every refund must be logged, and 40,000 reviews must be classified each night.
- Split the traffic into what a workflow handles and what needs an agent.
- Place the controls for the refund threshold and the refund log.
- Choose the design for the review classifier and justify it.
- Choose the runtime for the support agent, given the team runs its own servers.
Done when: every rule is enforced in code and each choice names its deciding constraint.
Show model answer
1. Order-status and simple return questions follow fixed paths (look up, explain, start return), so a router can send them into short workflows. Mixed or unclear requests ("my order arrived damaged and I want a different size") go to the agent, which chooses tools as it learns more.
2. The refund tool (or a PreToolUse hook) checks the amount and requires a supervisor approval token above $250; the harness writes a log entry with order number, amount and approver after every refund call. The prompt explains the policy but does not enforce it.
3. A batch workflow: one classification call per review through the Message Batches API at night, with counts aggregated in code. The results are not needed until morning, so batch halves the cost and no agent is needed.
4. A self-hosted Agent SDK harness on Juniper's servers: the team already runs the agent there and needs access to internal order systems. Claude Managed Agents would fit if they wanted hosted, sandboxed sessions without running servers.