الدرس 2 · الوحدة 4: Agentic Systems: Manager and Worker Agents
Designing the manager agent: planning, routing and delegating tasks
- Plan: split one message into clear tasks
- Route: pick the right worker for each task
- Delegate: write a brief a worker can't misread
Why this matters
Sara's shop inbox takes about sixty messages a day, and a single message often holds several unrelated requests. Without someone deciding who handles what, bookings get missed, quotes stall and receipts go unsent. This lesson shows how a manager agent reads each message, splits it into separate tasks, sends each task to the right worker, and hands over a clear brief so the work gets done without guesswork.
Key ideas
- Plan by splitting. Break one message into single tasks, each with one action and one result. If a task still contains "and", split it again.
- Route with rules first. A keyword table is the cheapest router. For example:
ROUTES = {"booking": ["book", "slot"], "quote": ["price", "cost"]}
text = "Book Friday and send the price"
print([w for w, words in ROUTES.items() if any(k in text.lower() for k in words)])
# ['booking', 'quote']
Unknown messages fall back to a human.
- Keep the manager narrow. The manager reads, plans, routes and writes briefs. It holds no work tools such as the calendar or price list. Workers hold those tools.
- Delegate with a five-part brief. Every worker gets a goal, inputs, the exact output format, a "done when" test and limits.
- Ask for JSON. A list of tasks in a fixed shape lets the next steps read the result without guessing.
Try it before you watch
A customer writes: "Can you hold a table for Friday and tell me the price of a birthday cake?" How many tasks should the manager create, and which worker gets each?
Show answerHide answer
Two tasks: a booking task for the Friday table (booking worker) and a quote task for the birthday cake price (quote worker). Splitting by single action shows that one message can need more than one worker.
Words to know
- manager agent: an AI agent whose only job is to plan, route and assign work to other agents.
- worker agent: an AI agent that holds the tools for one kind of task, such as a calendar or invoicing app.
- routing: choosing which worker should handle each task.
- brief: the written instructions a manager gives a worker for one task.
- classifier: a sorter that puts each item into one labelled group, such as booking, quote or human.
- JSON: a plain text format of labelled fields, like a filled-in form, that software can read reliably.
What to watch for
- How one customer message turns into three separate tasks before any worker starts.
- Why the keyword router sends the Friday message to two workers and the shipping question to a human.
- How each of the five brief parts removes a source of guessing for the worker.
تعلّمه مع معلمك على السبورة المباشرة
أهم نقاط الفيديو
The inbox that never sleeps
- Bloom Bakery gets 60 messages a day
- One message can hold three different requests
- Booking, pricing and receipts all land in one inbox
- Someone has to decide who handles what
layout: full
parts:
shop: {chip: Bloom Bakery}
steps:
- at: "Bloom Bakery online"
highlight: shop
note: "Sara's online shop"
- at: "sixty messages a day"
count: {to: 60, label: messages}
note: "The inbox fills all day"
- at: "a tasting on Saturday"
spokes: {of: shop, items: [Booking, Pricing, Receipts]}
note: "Three kinds of request"
- at: "three different requests"
highlight: shop
note: "One message, three requests"
- at: "all land in one inbox"
highlight: none
note: "One inbox for everything"
- at: "nobody in charge"
note: "A crowd with no leader"
- at: "decide who handles what"
note: "Who handles what?"
- at: "a team of agents"
note: "A team of agents"
- at: "design that manager"
highlight: shop
note: "Designing the manager" What you will learn
- Plan: split one message into clear tasks
- Route: pick the right worker for each task
- Delegate: write a brief a worker can't misread
layout: full
parts:
skills: {chip: This lesson, sub: "Three skills", icon: target}
steps:
- at: "do three things"
highlight: skills
note: "Three skills to learn"
- at: "First, plan"
spokes: {of: skills, items: [Plan, Route, Delegate]}
note: "Plan: one message, many tasks"
- at: "Second, route"
note: "Route: choose a worker"
- at: "Third, delegate"
note: "Delegate: write a clear brief"
- at: "needs code in your"
highlight: none
note: "No code needed"
- at: "a little Python"
note: "Python shows the logic only" The manager's three jobs
- The manager thinks and assigns; it doesn't do the work
- Workers have the tools: calendar, price list, invoices
- One clear output: a list of tasks with owners
layout: full
parts:
mgr: {chip: Manager, sub: "Thinks and assigns", icon: brain}
steps:
- at: "whole job on one page"
note: "The manager's whole job"
- at: "customer message comes in"
vortex: {into: mgr, words: [message, question, request]}
- at: "plans by listing the tasks"
spokes: {of: mgr, items: [Plan, Route, Delegate]}
- at: "routes each task"
note: "Route each task to a worker"
- at: "thinks and assigns"
highlight: mgr
note: "Thinks and assigns"
- at: "Workers have the tools"
note: "Workers hold the tools"
- at: "opens none of them"
highlight: none
note: "Never opens a work tool"
- at: "head waiter"
note: "Like a head waiter: never cooks"
- at: "Keeping the manager this narrow"
note: "Narrow means reliable"
- at: "each with an owner"
note: "A list of tasks, each with an owner" Planning: one message, three tasks
- Message: "Book a tasting Saturday, price 50 cupcakes, and resend my receipt"
- Task 1: find a Saturday tasting slot
- Task 2: quote 50 cupcakes
- Task 3: resend last month's receipt
layout: full
parts:
msg: {chip: Customer message, sub: "One message, three asks", icon: message-square}
steps:
- at: "Let's plan a real message"
highlight: msg
note: "A real message"
- at: "book a tasting on Saturday"
note: "Book a tasting, price 50 cupcakes, send receipt"
- at: "instantly sees three jobs"
spokes: {of: msg, items: [Slot, Quote, Resend]}
note: "Three jobs"
- at: "The first job is a free slot"
note: "Job 1: a free slot"
- at: "The second is a quote"
note: "Job 2: a quote"
- at: "The third is to resend"
note: "Job 3: resend the receipt"
- at: "on purpose"
highlight: none
note: "Every time, on purpose"
- at: "long message on the screen"
highlight: msg
note: "One long message"
- at: "still contains the word"
note: "Contains and? Split it again"
- at: "Small, single tasks"
note: "Small tasks are easy to check" Routing: the simple first layer
ROUTES = {
"booking": ["book", "appointment", "slot"],
"quote": ["price", "quote", "cost"],
"invoice": ["invoice", "receipt", "paid"],
}
def route(message):
text = message.lower()
tasks = []
for worker, words in ROUTES.items():
if any(w in text for w in words):
tasks.append(worker)
return tasks or ["human"]
msgs = [
"Can I book a tasting on Saturday?",
"What's the price for 50 cupcakes?",
"I paid but never got a receipt",
"Book Friday and send the quote",
"Do you ship to Canada?",
]
for m in msgs:
print(route(m), "<-", m) Delegating: the task brief
- Goal: one sentence, one result
- Inputs: the facts the worker needs
- Output: the exact format to return
- Done when: how the worker knows it's finished
- Limits: what it must never do
layout: full
parts:
brief: {chip: Task brief, sub: "Five parts", icon: clipboard-check}
steps:
- at: "hands each worker a brief"
highlight: brief
note: "The manager hands over a brief"
- at: "five parts"
spokes: {of: brief, items: [Goal, Inputs, Output, Done when, Limits]}
note: "Five parts"
- at: "The goal, one sentence"
note: "Goal: one sentence, one result"
- at: "The inputs, the facts"
note: "Inputs: the facts needed"
- at: "The output, the exact shape"
note: "Output: the exact format"
- at: "Done when, which tells"
note: "Done when: the worker knows it is finished"
- at: "And limits, such as"
note: "Limits: what it must never do"
- at: "how much guessing"
highlight: none
note: "Less guessing for the worker" The manager prompt in your tool
You are the manager of Bloom Bakery's
inbox. You never do the work yourself.
1. Read the message. List every request.
2. For each request pick ONE worker:
booking, quote, invoice, or human.
3. Write a brief for each worker:
goal, inputs, output, done-when, limits.
4. Reply only with JSON: a list of tasks.
If unsure, route to human. The manager's output for our message
[
{"worker": "booking",
"goal": "Find a Saturday tasting slot",
"inputs": "Customer Mona, Saturday",
"output": "One time slot + confirm line",
"done_when": "A free slot is held",
"limits": "Over $200 needs approval"},
{"worker": "quote",
"goal": "Price 50 cupcakes"},
{"worker": "invoice",
"goal": "Resend last month's receipt"}
] Worked example: one message, end to end
- Manager plans and routes; workers act
- Each worker reports back to the manager
- Manager writes one combined reply
layout: wide
direction: LR
components:
cust: {kind: user, label: Customer}
inbox: {kind: email, label: Inbox}
mgr: {kind: llm, label: Manager agent}
book: {kind: worker, label: Booking worker}
quote: {kind: worker, label: Quote worker}
inv: {kind: worker, label: Invoice worker}
links: [cust->inbox, inbox->mgr, mgr->book, mgr->quote, mgr->inv, mgr->cust]
steps:
- at: "the customer sends"
show: [cust, inbox]
- at: "reaches the manager"
show: [cust, inbox, mgr]
flow: ["cust>inbox: message", "inbox>mgr: new message"]
- at: "three briefs go out"
show: all
flow: ["mgr>book: brief", "mgr>quote: brief", "mgr>inv: brief"]
- at: "results come back"
flow: ["book>mgr: Sat 11:00", "quote>mgr: $95", "inv>mgr: sent"]
highlight: [mgr]
- at: "one friendly reply"
flow: ["mgr>cust: reply"] Common mistake: the do-everything manager
- Giving the manager every tool "just in case"
- It starts booking and pricing itself
- Workers sit idle, errors are hard to trace
- Fix: no work tools on the manager, only routing
layout: full
parts:
mgr: {chip: Manager, sub: "Does every job", icon: brain}
steps:
- at: "Here's the trap"
highlight: mgr
note: "The trap"
- at: "give the manager agent every tool"
note: "Every tool, just in case"
- at: "Its tools would be the calendar"
spokes: {of: mgr, items: [Calendar, Price list, Invoicing app]}
note: "Tools it should not hold"
- at: "doing the jobs itself"
highlight: mgr
note: "Doing the jobs itself"
- at: "sit idle"
note: "Workers sit idle"
- at: "something goes wrong"
note: "Which part failed?"
- at: "The fix is strict"
highlight: mgr
note: "Fix: no work tools"
- at: "gets no work tools"
note: "Only reading and routing"
- at: "another worker instead"
highlight: none
note: "Add a worker, not a tool" Recap
- Plan: split every message into single tasks
- Route: keywords first, a classifier for fuzzy cases, human as fallback
- Delegate: briefs with goal, inputs, output, done when, limits
layout: full
parts:
recap: {chip: Recap, sub: "Three takeaways", icon: list-checks}
steps:
- at: "Plan: split every message"
spokes: {of: recap, items: [Plan, Route, Delegate]}
- at: "keyword rules, a classifier"
highlight: recap
note: "Keywords, then a classifier"
- at: "and always falling back to a human"
note: "Human as fallback"
- at: "five-part brief"
note: "Five-part brief"
- at: "That calm comes from a manager"
highlight: none Your exercise
- Collect 10 real messages from your inbox (or invent them)
- For each: list the tasks and pick a worker
- Write one full brief for the hardest task
- Note every message you'd send to a human
layout: full
parts:
task: {chip: Exercise, sub: "Ten messages", icon: clipboard-check}
steps:
- at: "Collect 10 real messages"
spokes: {of: task, items: [Collect 10, Pick workers, Write a brief, Note humans]}
- at: "list the tasks inside it"
highlight: task
- at: "Then pick the hardest task"
note: "Pick the hardest task"
- at: "Finally, note every message"
highlight: none
note: "Note the human messages"
- at: "Bring this list to the next lesson"
note: "Bring the list" النص المكتوب
The inbox that never sleeps. Picture Sara, who runs Bloom Bakery online. Her phone buzzes with about sixty messages a day. One customer wants a tasting on Saturday, a price for fifty cupcakes, and a receipt for last month, all in a single message. That is three different requests in one message. Booking, pricing and receipts all land in one inbox. But a team with nobody in charge is just a crowd, isn't it? Someone has to decide who handles what. In the last lesson you saw that a team of agents can share this load. Today you'll design that manager, the agent Sara could trust with her whole shop.
What you will learn. By the end of this lesson you'll be able to do three things. First, plan, which means turning one messy customer message into a short list of separate tasks. Second, route, which means choosing which worker agent gets each task. Third, delegate, which means writing a short brief for that worker so it knows exactly what to do and when it's finished. None of this needs code in your no-code tool. I'll show a little Python only to make the logic visible, the same logic you'll type into a prompt.
The manager's three jobs. Here's the whole job on one page. A customer message comes in, and the manager plans by listing the tasks inside it. It routes each task to a worker, then delegates by writing a brief for that worker. The manager thinks and assigns, so it never does the work itself. Workers have the tools: the calendar, the price list and the invoices. The manager opens none of them. Think of a restaurant head waiter who takes the order and passes the tickets to the kitchen, but never cooks. Keeping the manager this narrow is what makes it reliable. One clear output: a list of tasks, each with an owner.
Planning: one message, three tasks. Let's plan a real message. The customer writes: book a tasting on Saturday, price 50 cupcakes, and send my receipt again. A person reads that and instantly sees three jobs. The first job is a free slot on Saturday. The second is a quote for fifty cupcakes. The third is to resend last month's receipt. The manager must do the same, on purpose. Picture the long message on the screen, then three sticky notes on the wall, one per job. If a task still contains the word and, it's probably two tasks, so split it again. Small, single tasks are much easier to route and much easier to check later.
Routing: the simple first layer. Routing means picking a worker for each task. The cheapest version is a keyword table. Look at the top of the code: booking words go to the booking worker, price words to the quote worker, receipt words to the invoice worker. The middle part checks the message against each list in turn. The last line of the function says: if nothing matched, send it to a human. Run it and look at the output. The Friday message gets two workers at once. And the shipping question matches nothing, so it falls back to a human, which is exactly what we want. Keywords miss fuzzy wording, and they can also match the wrong word, because notebook contains book and unpaid contains paid. So in practice you add a language model as a classifier. A language model is the AI that reads and writes text, like ChatGPT. A classifier is just a sorter that puts each item into one of a few labelled boxes, like sorting post into pigeonholes.
Delegating: the task brief. Delegating means the manager hands each worker a brief, like a manager passing a clipboard across the desk. A good brief has five parts. The goal, one sentence with one result. The inputs, the facts the worker needs, such as the customer's name and the date they asked for. The output, the exact shape of the answer, for example a time slot and a confirmation line. Done when, which tells the worker what finished looks like, so it doesn't keep going. And limits, such as never confirming a booking that costs over two hundred dollars without approval. Notice how much guessing that removes from the worker's side?
The manager prompt in your tool. In a no-code tool like n8n, the manager is an AI Agent step, and everything we've covered goes into its prompt. A prompt is simply the written instructions you give the model. Read it from the top: you're the manager, you never do the work, list every request, pick one worker each, write a five-part brief, and reply only in JSON. JSON is a plain text format of labelled fields, like a filled-in form, which the next steps in your workflow can read without guessing. That last line, if unsure, route to human, is the cheapest safety feature you'll ever add.
The manager's output for our message. Here is what the manager actually sends back for our bakery message: a list of three tasks, one per worker. Look at the first one, the booking task, written out in full. The goal is to find a Saturday tasting slot. The inputs are the customer's name and the day she asked for. The output is one time slot and a line to confirm it. It's done when a free slot is held. And the limit says anything over two hundred dollars needs approval. The quote and invoice tasks get the same five parts; here we show only their goals to save space. This list is the whole of the manager's work, and every worker can act on it without asking a single question.
Worked example: one message, end to end. Let's run the whole thing. First the customer sends the three-part message into Sara's inbox. It then reaches the manager agent, which plans three tasks and routes each one. Now three briefs go out: to the booking worker, the quote worker and the invoice worker. Each worker uses its own tool, the calendar, the price list, the invoicing app. Then the results come back: Saturday at eleven, ninety-five dollars for fifty cupcakes, and the receipt resent. The manager writes one friendly reply that covers everything, and the customer never sees the team behind it.
Common mistake: the do-everything manager. Here's the trap almost everyone falls into. You give the manager agent every tool, just in case. Its tools would be the calendar, the price list and the invoicing app. Soon it starts doing the jobs itself, half booking and half pricing, while the workers sit idle. When something goes wrong, say a double-booked Saturday, you can't tell which part failed. The fix is strict. The manager gets no work tools at all, only reading, planning, routing and writing briefs. If you catch yourself adding a tool to the manager, that's a sign you need another worker instead.
Recap. Let's pull it together. The manager plans by splitting each message into single tasks, one action and one result each. It routes those tasks, starting with cheap keyword rules, adding a language model classifier for fuzzy wording, and always falling back to a human. And it delegates with a five-part brief: goal, inputs, output, done when, and limits. Look at Sara now, drinking her coffee while the trays move along the counter in order. That calm comes from a manager that only manages.
Your exercise. Now it's your turn, and you don't need any tool yet. Take ten real messages from your own business inbox, or invent ten for a small shop you know. For each one, list the tasks inside it and choose a worker: booking, quote, invoice or human. Then pick the hardest task and write its full brief with all five parts. Finally, note every message you'd send to a human and why. Bring this list to the next lesson, because we'll build the worker agents that receive these exact briefs.
استكشف الرسوم المتحركة
الرسوم المتحركة نفسها التي في الفيديو، دقيقة وتفاعلية: شغّلها أو أوقفها، أو اسحب المؤشر، أو انتقل إلى أي خطوة بالسرعة التي تناسبك.
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
أجب عن كل الأسئلة ثم تحقّق. تنجح بنسبة 70%، ويمكنك إعادة المحاولة كما تشاء.
ملخص الدرس
- القراءة
- مشاهدة الفيديو
- اجتياز الاختبار (70%)
- Plan: split every message into single tasks
- Route: keywords first, a classifier for fuzzy cases, human as fallback
- Delegate: briefs with goal, inputs, output, done when, limits