Recommended resources
The freely available resources this lesson will direct you to.
- Vercel Ship 2025 workshop: Building agents with the AI SDK (Nico Albanese)www.youtube.com
- After This Video, You'll Actually Understand Agent Orchestrationwww.youtube.com
- Best Practices for Prompts in AI Agent Studio | fusioncoeblogs.oracle.com
- How we built our multi-agent research systemwww.anthropic.com
In our last lesson, we established the core mechanics of delegation, learning how to wrap a worker agent inside a tool that a supervisor agent can call. We built the "plumbing" for a hierarchical system. However, providing the mechanism is only half the story. An uninstructed supervisor is like a manager with a team but no plan—ineffective and unpredictable.
This lesson focuses on crafting the "brain" of the supervisor: the delegation prompt. You will learn to design precise instructions that transform your supervisor from a simple tool-caller into an intelligent coordinator. We will move beyond the code and delve into the art and science of prompt engineering, which is the primary lever for controlling agent behavior in a multi-agent system. Your goal is to create a supervisor that understands its role, knows its team's capabilities, and makes smart decisions about who should handle a given task.
1. From Mechanism to Intelligence: The Role of the Delegation Prompt
In a hierarchical agent system, the supervisor acts as the central router. Its main task is to decompose a user's request and delegate sub-tasks to the appropriate specialized worker agents.
Imagine we have built the following system for a medical clinic:

We have the Supervisor Agent and three workers: Availability Agent, Booking Agent, and FAQs Agent. We've wrapped each worker in a callable tool, just as we learned in the previous lesson.
Now, consider this user request: "I'd like to book an appointment with a cardiologist next Tuesday and also ask what insurance plans you accept."
How does the Supervisor Agent know what to do?
- Should it try to answer directly? (No)
- Should it call the
Booking Agentfirst, or theFAQs Agent? - How does it even know what each of these agents can do?
The answer to all these questions lies in the supervisor's system prompt. The delegation prompt is not a separate entity, but rather a crucial part of the supervisor's main system prompt that specifically instructs it on its role as an orchestrator. Without clear instructions, the LLM powering the supervisor will likely fail, either by trying to do the work itself, hallucinating capabilities, or choosing the wrong worker.
2. Core Principles of a Delegation Prompt
Crafting an effective delegation prompt is a task of precision. The goal is to constrain the agent's behavior to only orchestration while giving it enough information to make correct routing decisions. Let's explore the fundamental principles, drawing from industry best practices.
The team at Anthropic, in their work on multi-agent systems, found that prompt engineering was their primary tool for improving agent coordination.
How we built our multi-agent research system
This article from Anthropic details their journey in building a complex multi-agent system and the prompting principles they discovered.
Read the introduction under the heading Prompt engineering and evaluations. Then, focus on the second principle, Teach the orchestrator how to delegate. This section highlights the need for detailed task descriptions, including objectives, output formats, and clear boundaries.
Building on these insights, we can establish three core principles for our delegation prompts.
Principle 1: Define the Role and Its Boundaries
First and foremost, the prompt must explicitly state the supervisor's role and, crucially, what it should not do. This is the most common source of error in hierarchical systems.
The Oracle AI team puts this succinctly:
Best Practices for Prompts in AI Agent Studio | fusioncoe
This blog post provides tactical guidance for production-quality agent teams, with a strong focus on clear role definition and boundary setting.
Read the sections Defining Agent Roles with Precision and <to_complete> Setting Responsibility Boundaries. Note the clear distinction between a supervisor's orchestration role and a worker's execution role.
Your prompt must contain an unambiguous instruction like this:
"You are a supervisor agent. Your sole responsibility is to analyze user requests and delegate them to the appropriate worker agent. You must never attempt to answer questions or perform tasks yourself. Your value is in orchestration, not execution."
This instruction prevents the supervisor from overstepping its bounds and trying to handle a task that a specialized worker is better equipped for.
Principle 2: Describe the Workers (Tools) with High Fidelity
The supervisor interacts with workers via tools. Therefore, the description field of each delegation tool is the supervisor's primary source of knowledge about its team's capabilities. A vague description leads to poor delegation.
This is a universal principle in tool-using agents. In the context of the Vercel AI SDK, precise tool descriptions are critical for the model to make correct choices.
Vercel Ship 2025 workshop: Building agents with the AI SDK (Nico Albanese)
In this workshop on the Vercel AI SDK, Nico Albanese explains the fundamentals of tool definition. His emphasis on the importance of the description field is directly applicable to our delegation tools.
Watch the segment from the importance of this description. The speaker states, "I cannot overstate the importance of this description... as your tool set balloons out... you'll want to be as descriptive as you can to help the model pick the right tools for the right job."
Consider a researchTool that wraps our researchAgent.
- Vague Description ❌:
"A tool for research."(What kind of research? What are its limitations?) - Precise Description ✅:
"Delegates a research task to a specialized research analyst agent. Use this for any request that requires finding, reading, analyzing, or synthesizing information from external web sources or internal documents. Do not use for simple factual questions that don't require analysis."
The precise description gives the supervisor a much clearer signal about when and why to use this particular worker.
Principle 3: Provide Explicit Delegation Logic and Workflow
Beyond describing the tools, you can embed logic directly into the prompt to guide the supervisor's decision-making process. This can include an explicit workflow, rules for choosing agents, and instructions on how to handle ambiguity.
After This Video, You'll Actually Understand Agent Orchestration
This video by Burke Holland provides an excellent walkthrough of a practical agent orchestration setup, showing the exact prompts used to control the system.
First, watch the section describing the orchestrator's prompt from the prompt is fairly simple. Notice how it explicitly lists the available sub-agents and defines a clear workflow: understand, plan, delegate, coordinate, report. Then, see this in action from from our prompt here, where the orchestrator follows the plan, calling the planner, then the designer, then the coder in sequence.
This workflow can be codified in your supervisor's prompt, turning implicit understanding into an explicit algorithm for the LLM to follow.
3. A Practical Implementation
Let's apply these principles by refining the supervisor-agent.ts we conceptualized in the previous lesson. We'll create a system prompt that embodies our three principles for the "Appointment Booking" system shown earlier.
Assume we have created createBookingTool and createFaqsTool in the same way we created createResearchTool.
// /lib/agents/supervisor-agent.ts
import { ToolLoopAgent } from 'ai';
import { openai } from '@ai-sdk/openai';
import { createBookingTool } from '@/lib/tools/delegation/create-booking-tool';
import { createAvailabilityTool } from '@/lib/tools/delegation/create-availability-tool';
import { createFaqsTool } from '@/lib/tools/delegation/create-faqs-tool';
// 1. Initialize the tools that wrap our worker agents
const bookingTool = createBookingTool();
const availabilityTool = createAvailabilityTool();
const faqsTool = createFaqsTool();
// 2. Craft the detailed delegation prompt
const supervisorInstructions = `
You are the Supervisor Agent for a medical clinic's appointment booking system. You function as an intelligent router and coordinator. Your one and only job is to analyze incoming user requests and delegate them to the correct specialized worker agent.
---
### **Core Principles**
1. **Orchestrate, Do Not Execute:** You are strictly forbidden from answering questions or performing tasks directly. Your entire purpose is to delegate. If a request is unclear or does not fit any available worker, you must state that you cannot handle the request and explain why.
2. **Analyze Intent:** Carefully examine the user's request to understand its core intent. A single user message may contain multiple intents that need to be handled sequentially.
3. **Use Your Tools:** You must use the provided tools to delegate tasks to worker agents. The tool descriptions are your guide to their capabilities.
---
### **Workflow**
1. Receive and analyze the user's prompt.
2. Based on the user's intent, select the single best worker agent to handle the immediate task.
3. Call the corresponding tool, passing a clear and concise instruction as the 'task' input.
4. Once the worker agent completes its task, present its findings to the user. If the initial request had multiple parts, re-evaluate and decide if another worker needs to be called.
---
### **Available Worker Agents**
* **availability**: Use this agent to check for available appointment slots. It can check by doctor, by specialization, or by date.
* **booking**: Use this agent to set, cancel, or reschedule an appointment. It also handles sending confirmation emails.
* **faqs**: Use this agent to answer general questions about the clinic, such as insurance plans, doctor credentials, or office hours.
`;
// 3. Define the supervisor agent with its instructions and tools
export const supervisorAgent = new ToolLoopAgent({
model: openai('gpt-4o'),
instructions: supervisorInstructions,
tools: {
availability: availabilityTool,
booking: bookingTool,
faqs: faqsTool,
},
});
This prompt is far more robust than a simple one-liner. It clearly defines the supervisor's role, its boundaries, the tools at its disposal, and the process it should follow. Using Markdown and clear headings helps the LLM parse and adhere to the instructions more reliably.
4. Advanced Technique: Granting Autonomy to Workers
A common failure pattern in hierarchical systems is when a well-meaning supervisor tries to micromanage its workers. It might pass an overly detailed instruction like, "Change line 42 in app.js to const x = 5;". This defeats the purpose of having a specialized worker that should have its own expertise.
A powerful counter-measure is to include instructions in the worker's prompt that grant it autonomy.
After This Video, You'll Actually Understand Agent Orchestration
Let's return to Burke Holland's video. He addresses this exact problem by empowering his sub-agents to think for themselves.
Watch the segment on the coder and designer prompts from except for this block right here and from Don't let the orchestrator tell you how to do your job. The key instruction is: "Question everything you're told. Make your own decisions." This makes the entire system more robust by preventing the orchestrator from imposing flawed implementation details.
While this instruction is part of the worker's prompt, designing it is a key part of the overall delegation strategy. You, as the architect, are designing a system where specialists are trusted to do their jobs, and the supervisor is trusted only to coordinate.
Conclusion
In this lesson, we elevated our supervisor agent from a simple mechanism to an intelligent coordinator. You learned that the delegation prompt is the critical component for directing a supervisor's behavior and that effective prompts are built on clear principles.
Key Takeaways:
- Prompting is the Control Lever: The supervisor's system prompt is the primary way to control its delegation behavior.
- Define and Constrain: An effective delegation prompt explicitly defines the supervisor's role as an orchestrator and strictly forbids it from executing tasks itself.
- Descriptions are Your API: The
descriptionfield of your delegation tools is the API contract for your worker agents. Make it precise, accurate, and comprehensive. - Codify the Workflow: Embedding a clear workflow and decision-making logic into the prompt helps the LLM behave more predictably and reliably.
- Design for Autonomy: A robust multi-agent system trusts its specialists. Build autonomy into your worker prompts to prevent supervisor micromanagement.
We've now instructed the supervisor when and why to delegate. In our next lesson, we will focus on the specifics of the handoff: "Pass context and instructions from a parent agent to child agents." We will explore how to structure the inputSchema of our delegation tools to pass rich, structured data, ensuring the worker has all the information it needs to succeed.