Multi-Step Agent Workflows

Design and prompt complex agent workflows with planning, delegation, and error recovery.

8 min read
2 quiz questions

Real-world tasks often require multiple steps: research a topic, draft a document, check it for errors, then format it. Multi-step agent workflows break complex tasks into phases, with the agent managing state and transitions between them.

The most impactful pattern for multi-step workflows is plan-then-execute. Before taking any action, the agent creates an explicit plan. This reduces wasted steps, improves coherence across steps, and makes the workflow observable and debuggable.

Plan-then-execute prompt: "Before taking any action, create a numbered plan of steps needed to complete this task. For each step, note which tool you'll use and what input you'll provide. Then execute the plan step by step, updating it if you discover new information." Agent output: Plan: 1. Search knowledge base for current pricing → search() 2. Pull customer's order history → get_orders() 3. Calculate discount eligibility → calculate() 4. Draft response email → compose() 5. Get user approval → ask_user() Executing step 1...

For very complex workflows, a single agent can struggle. Multi-agent patterns use an orchestrator agent that delegates subtasks to specialist agents. The orchestrator handles planning and coordination while specialists handle domain-specific work (research, coding, analysis, writing).

Agents fail. Tools return errors, plans hit dead ends, and outputs contain mistakes. Robust agents need explicit error recovery instructions: retry with different parameters, try alternative tools, simplify the approach, or escalate to the user.

Always include a "checkpoint" pattern for long workflows: after every 3-5 steps, the agent should summarize progress, verify it's on track, and re-evaluate its plan. This prevents compounding errors.

Prompt Templates

Plan-Then-Execute Agent

Full multi-step agent prompt with planning, execution, checkpoints, and error handling.

You are a task execution agent. For any request:

1. PLAN: Create a numbered list of steps, each with the tool you'll use
2. EXECUTE: Run each step, showing Thought → Action → Result
3. CHECKPOINT: After every 3 steps, summarize progress and verify you're on track
4. COMPLETE: Deliver the final result with a summary of what was done

If any step fails, note the error and try an alternative approach before continuing.

Task: [TASK]

Orchestrator Agent

Orchestrates multiple specialist agents for complex multi-domain tasks.

You are an orchestrator managing specialist agents. Break this task into subtasks and delegate each to the appropriate specialist:

- Researcher: finds information (call with research(query))
- Analyst: processes data (call with analyze(data, question))
- Writer: creates content (call with write(brief))

Coordinate their work: plan the order, pass outputs between specialists, and assemble the final deliverable.

Task: [COMPLEX TASK]

Test Your Knowledge

Knowledge Check

1 / 2

Why is plan-then-execute superior to acting immediately?

Key Takeaways

  • Plan-then-execute reduces wasted tool calls and makes multi-step workflows observable and debuggable
  • Multi-agent delegation uses an orchestrator to coordinate specialist agents for complex tasks
  • Build in checkpoints every 3-5 steps and explicit error recovery paths to handle failures gracefully