LIVE WORKSHOP ยท 20 MINUTES

Build a Sub-Agent Orchestrator

Use Claude Code to build a main agent that reads a sales lead and decides at runtime which sub-agents to spawn โ€” different research depth for different deal sizes.

1
Main Orchestrator
2โ€“5
Sub-Agents (adaptive)
1
Lead Brief + Email
Your Pipeline Architecture โ€” Sub-Agents Spawn Based on Lead Tier
โ–ถ
Main Agent
reads + decides
ICP Fit Agent
always
Company Intel Agent
if deal > $10k
Buyer Persona Agent
if VP or above
Email Draft Agent
always last
Lead Brief
+ email draft
Progress0%
Welcome
Read before starting

Sub-Agent Orchestrator:
The Agent That Decides

In the parallel workshop, the fan-out was fixed โ€” all 3 agents always ran. In this workshop, the main agent reads the situation first and decides which sub-agents are needed. A $5k SMB lead gets 2 sub-agents. A $200k enterprise lead gets 5.

โ—ˆ What is AI Agent Type 7 โ€” Sub-Agent Orchestrator?

A main orchestrating agent reads the input, classifies it, and dynamically spawns only the sub-agents the task actually requires. The branching is a runtime decision โ€” not pre-defined. Each sub-agent is a specialist; the orchestrator is the strategist that decides who to call.

Type 4 โ€” Parallel

Fan-out defined at build time. All 3 agents always run. Good when every task has identical structure.

Static fan-out
VS
Type 7 โ€” Orchestrator

Main agent decides at runtime. A simple lead gets 2 sub-agents. An enterprise deal gets 5. Only pays for what it needs.

Adaptive fan-out
Your Use Case: Adaptive Lead Qualification

When a new lead comes in, the orchestrator reads the lead data and decides how deep to research โ€” saving time and cost on low-value leads, while doing full due diligence on high-value ones.

Sub-AgentWhat It DoesWhen It Spawns
ICP Fit AgentScore 0โ€“100 against your ideal customer profile definitionAlways
Company Intel AgentFunding stage, headcount, tech stack, growth signalsDeal > $10k
Buyer Persona AgentLinkedIn role, tenure, past companies, recent postsTitle is VP+
Competitor Usage AgentDetect current tooling from job posts and tech signalsEnterprise flag
Email Draft AgentWrite personalised first email using all other agents' outputAlways last
What You Need
Step 1 of 4
๐ŸŸ  Main Orchestrator ยท โฑ 6 minutes

Stage 1: Main Orchestrator Agent
Read the Lead, Decide the Depth

This is the brain of the system. It reads the lead data, classifies the deal tier, then writes a spawn plan โ€” a JSON file that tells the next stage exactly which sub-agents to run and why.

The Orchestrator's Decision Logic The main agent reads: company size, title seniority, estimated deal size, and any keywords that signal enterprise vs SMB. Based on these signals, it produces a spawn plan listing which sub-agents should run and what input to pass each one. This is the key difference from parallel โ€” the branching is a thought, not a pre-set.
How to Run Stage 1
  1. Open your terminal and create a working directory: cd ~/Desktop && mkdir lead-orchestrator && cd lead-orchestrator
  2. Launch Claude Code: claude
  3. Copy the Stage 1 prompt below โ€” it includes a sample lead to analyse. Paste into Claude Code and hit Enter.
  4. Watch the orchestrator reason about the lead and produce a spawn_plan.json with its decision.
Stage 1 โ€” Orchestrator Agent Prompt
STAGE_1_ORCHESTRATOR.txt โ€” Paste into Claude Code terminal ๐ŸŸ  Main Orchestrator
You are the main orchestrator agent for a lead qualification system. Your job is to read a new inbound lead, classify it, and produce a spawn plan โ€” a structured decision about which sub-agents to run. ## LEAD DATA (your input for this workshop) Process this lead: { "first_name": "Sarah", "last_name": "Chen", "title": "VP of Sales Operations", "company": "Meridian Health Partners", "company_size_signal": "Series B, ~400 employees", "industry": "Healthcare Technology", "how_they_found_us": "LinkedIn ad โ€” Zara scheduling agent", "message": "We coordinate scheduling across 12 clinical sites and 200+ clinicians. Our current process is entirely manual. Looking for an AI solution that can handle cross-org scheduling at scale.", "email": "s.chen@meridianhealth.io" } ## YOUR DECISION FRAMEWORK Analyse this lead and classify it on these dimensions: DEAL SIZE ESTIMATE: - Signals of enterprise scale (200+ users, multi-site, clinical) โ†’ Likely $50k+ - Mid-market signals (50โ€“200 users, single org) โ†’ Likely $10kโ€“$50k - SMB signals (<50 users, single user) โ†’ Likely <$10k TITLE SENIORITY: - C-suite, VP, SVP, EVP, Partner โ†’ "senior" - Director, Head of, Senior Manager โ†’ "mid" - Manager, Specialist, Individual Contributor โ†’ "junior" URGENCY SIGNALS: - Words like "current process is broken", "manual", "scaling problem", "urgently" โ†’ "high" - Exploratory language, "looking into", "evaluating" โ†’ "medium" - No clear pain stated โ†’ "low" ## SPAWN PLAN RULES Based on your classification, decide which sub-agents to activate: Always activate: โœ… icp_fit_agent โ€” score against ANCI ICP (cross-org scheduling, enterprise, VP+ buyer) โœ… email_draft_agent โ€” always runs last after all other agents complete Conditionally activate: if deal_size_estimate >= $10k: โœ… company_intel_agent if title_seniority == "senior": โœ… buyer_persona_agent if deal_size_estimate >= $50k OR company_size > 100 employees: โœ… competitor_usage_agent ## OUTPUT Save a file called spawn_plan.json with this structure: { "lead_summary": "one sentence describing this lead", "classification": { "deal_size_estimate": "$50k+", "deal_tier": "enterprise | mid-market | smb", "title_seniority": "senior | mid | junior", "urgency": "high | medium | low", "key_signals": ["list of 3โ€“5 signals that drove the classification"] }, "spawn_decision": { "agents_to_run": ["icp_fit_agent", "company_intel_agent", "buyer_persona_agent", "competitor_usage_agent", "email_draft_agent"], "agents_skipped": [], "reasoning": "one paragraph explaining why each activated agent was chosen", "execution_order": "parallel_first_then_email: run first 4 in parallel, email_draft_agent reads all their outputs last" }, "context_for_each_agent": { "icp_fit_agent": { "focus": "cross-org scheduling, 200+ clinicians, healthcare vertical" }, "company_intel_agent": { "company": "Meridian Health Partners", "focus": "Series B health tech" }, "buyer_persona_agent": { "person": "Sarah Chen", "title": "VP Sales Operations", "company": "Meridian Health Partners" }, "competitor_usage_agent": { "company": "Meridian Health Partners", "signals_to_look_for": "Calendly, scheduling tools, EHR integrations" }, "email_draft_agent": { "tone": "senior executive, consultative, reference clinical scale" } } } Print: "โœ… Stage 1 Complete โ€” spawn_plan.json saved" Print: "โ—ˆ Orchestrator decision: [N] agents activated for [deal_tier] lead ([deal_size_estimate])" Print: "Agents queued: [list the agents_to_run]"
Stage 1 Success Checklist
Step 2 of 4
๐ŸŸก Sub-Agents ยท โฑ 7 minutes

Stage 2: Sub-Agent Execution
Each Specialist Does Its Job

The sub-agents now execute based on the spawn plan from Stage 1. This prompt tells Claude Code to read the spawn plan, run each activated agent, and save their individual outputs โ€” ready for the email draft agent in Stage 3.

What Makes This Different If you changed Sarah's title to "Marketing Coordinator" and company size to "15 employees", Stage 1 would have produced a different spawn plan โ€” fewer agents, different context. The sub-agents don't change. The orchestrator's decision does.
Stage 2 โ€” Sub-Agent Execution Prompt
STAGE_2_SUBAGENTS.txt โ€” Paste into the same Claude Code session ๐ŸŸก Sub-Agent Runner
You are a sub-agent runner. Read spawn_plan.json to know which agents to run, then execute each one and save their outputs. ## YOUR TASK 1. Read spawn_plan.json 2. For each agent listed in agents_to_run (except email_draft_agent โ€” that runs last in Stage 3): - Execute that agent using the context provided in context_for_each_agent - Save its output to a separate file 3. Run the research agents in parallel where possible (use Promise.all for web searches) ## AGENT IMPLEMENTATIONS ICP FIT AGENT (always runs) ANCI ICP definition: - Ideal buyer: Operations leader (VP, Director, Head of) managing scheduling across multiple teams or sites - Ideal company: 50โ€“5000 employees, multi-location or multi-team, needs cross-org coordination - Pain: Manual scheduling bottlenecks, calendar conflicts, cross-team coordination overhead - Budget: $10kโ€“$200k/year - Industry: Healthcare, Professional Services, Staffing, SaaS, Enterprise Tech Score the lead 0โ€“100 on ICP fit. Break down the score: - Buyer seniority match (0โ€“25) - Company size match (0โ€“25) - Pain signal match (0โ€“25) - Industry match (0โ€“25) Save as output_icp_fit.json: { "score": 0-100, "tier": "A|B|C|D", "breakdown": {...}, "top_fit_signals": [], "gaps": [] } COMPANY INTEL AGENT (if activated) Research Meridian Health Partners using web search: - Funding stage and amount raised - Headcount and growth rate - Locations / number of sites - Technology signals (job posts, Linkedin, Crunchbase) - Any news from last 90 days Save as output_company_intel.json: { "company": "...", "funding": "...", "headcount": "...", "locations": [], "tech_signals": [], "recent_news": [] } BUYER PERSONA AGENT (if activated) Research Sarah Chen, VP Sales Operations at Meridian Health Partners: - LinkedIn signals (recent posts, tenure, past companies) - Role responsibilities typical for this title in health tech - Likely pain points a VP Sales Ops faces in clinical scheduling coordination - Communication style signals from any public content Save as output_buyer_persona.json: { "person": "...", "tenure_signal": "...", "past_companies": [], "likely_pain_points": [], "communication_style": "...", "talking_points": [] } COMPETITOR USAGE AGENT (if activated) Search for signals that Meridian Health Partners currently uses scheduling tools: - Job postings mentioning specific tools (Calendly, Acuity, scheduling software) - LinkedIn employee posts about scheduling pain - Any integrations visible in job descriptions (EHR systems, calendar tools) Save as output_competitor_usage.json: { "current_tools_detected": [], "ehr_signals": [], "scheduling_maturity": "manual|basic|advanced", "displacement_angle": "..." } ## COMPLETION After all agents complete, print: "โœ… Stage 2 Complete โ€” sub-agent outputs saved" For each agent run: " โœ“ [agent_name] โ†’ [output_filename] (key finding: [one sentence])"
Stage 2 Success Checklist
Step 3 of 4
๐ŸŸข Lead Brief + Email Draft ยท โฑ 4 minutes

Stage 3: Lead Brief & Email Agent
Assemble All Outputs Into One Deliverable

The email draft agent is the last to run โ€” it reads every sub-agent's output and synthesises them into a lead brief card and a personalised first email, ready to send from your CRM.

Stage 3 โ€” Lead Brief + Email Prompt
STAGE_3_LEADBRIEF.txt โ€” Paste into the same Claude Code session ๐ŸŸข Final Output Agent
You are the final output agent in a lead qualification orchestrator. Read all sub-agent outputs and produce two deliverables: a lead brief and a personalised first email. ## READ THESE FILES (all from current directory) - spawn_plan.json (orchestrator decision + lead summary) - output_icp_fit.json (ICP score and tier) - output_company_intel.json (company research โ€” if exists) - output_buyer_persona.json (buyer research โ€” if exists) - output_competitor_usage.json (competitor signals โ€” if exists) If any file is missing, note it as "agent not activated for this lead tier". ## DELIVERABLE 1: LEAD BRIEF HTML PAGE Generate lead_brief.html โ€” a CRM-ready lead card an account executive would open before a call. Design: Clean white card, inline CSS, professional. Colors: #1A6BFF (primary), #10B981 (positive), #EF4444 (risk). Include: 1. LEAD HEADER: Name, title, company, email โ€” plus ICP score badge (A/B/C/D) in top right corner 2. ORCHESTRATOR DECISION BOX (light blue background) "This [deal_tier] lead activated [N] of 5 possible sub-agents." Show which agents ran (โœ“ green) and which were skipped (โ—‹ grey) and why 3. ICP FIT SECTION Score bar (0โ€“100), tier badge, top fit signals as green tags, gaps as yellow tags 4. COMPANY SNAPSHOT (if company_intel ran) Funding, headcount, locations, key tech signals as a clean fact table 5. BUYER INTEL (if buyer_persona ran) Tenure, past companies, pain points, recommended talking points 6. COMPETITIVE CONTEXT (if competitor_usage ran) Current tools detected, displacement angle, scheduling maturity rating 7. RECOMMENDED APPROACH Based on all outputs: deal tier, suggested demo angle, key objection to prepare for, ideal next step 8. FOOTER "Generated by Type 7 Sub-Agent Orchestrator | ANCI AI ยท anci.app" "Agents activated: [list] | Lead tier: [tier] | ICP Score: [N]/100" ## DELIVERABLE 2: PERSONALISED FIRST EMAIL Generate first_email.txt โ€” a ready-to-send email from an ANCI account executive to Sarah Chen. Requirements: - Subject line: reference her specific pain (multi-site clinical scheduling) โ€” not generic - Opening line: reference a specific signal from buyer_persona or company_intel โ€” not "I saw you visited our website" - Body: 3โ€“4 sentences. Acknowledge the scale problem (200+ clinicians, 12 sites). Reference one specific ANCI capability (cross-org scheduling, Zara agent). One social proof point relevant to healthcare if found. - CTA: Book a 20-minute demo โ€” use a Calendly-style link placeholder [DEMO_LINK] - Signature: [Your Name], ANCI AI | anci.app - Tone: senior-to-senior, consultative. No buzzwords. No "hope this email finds you well". After saving both files, print: "โœ… Stage 3 Complete โ€” lead_brief.html and first_email.txt saved" "Open lead_brief.html in your browser to see the full lead card" "The email in first_email.txt is ready to copy into your CRM"
Stage 3 Success Checklist
โ—ˆ

Workshop Complete!

Your Type 7 Sub-Agent Orchestrator qualified a lead adaptively โ€” spawning only the agents that deal warranted.

1
Orchestrator
4
Sub-Agents Run
2
Deliverables
20
Minutes
Open Your Outputs
  1. In your terminal: open lead_brief.html โ€” review the orchestrator decision box to confirm which agents ran and which were skipped
  2. Open first_email.txt โ€” check that the subject line and opening reference Sarah's specific context, not generic language
  3. Now try changing the lead: edit the title to "Marketing Coordinator" and company size to "12 employees" in Stage 1. Re-run all 3 stages. The orchestrator should spawn fewer agents.
What You Can Build Next
๐Ÿ”—
Connect to HubSpot

Trigger the orchestrator automatically when a new contact is created in your CRM via webhook.

๐Ÿ“Š
Add a Scoring Rubric

Store your ICP definition in Notion and have the ICP agent fetch it dynamically โ€” so your scoring updates without code changes.

๐Ÿ“ง
Auto-send the Email

Add a Stage 4 Gmail agent that sends the drafted email with a 2-hour delay and logs the send in CRM.

๐Ÿ—‚
Multi-lead Batch

Wrap in a loop: feed 10 leads, the orchestrator decides depth per lead, all run in parallel per-lead, results saved to a sheet.

The Full Agent Architecture You've Now Built

๐Ÿ“˜ Type 3 โ€” Sequential Pipeline

cal.com GitHub โ†’ Analysis โ†’ HTML Dashboard. Each stage hands off to the next.

โ‡‰ Type 4 โ€” Parallel Execution

3 competitor agents run simultaneously. Merge + dashboard. Wall-clock time = slowest branch.

โ—ˆ Type 7 โ€” Sub-Agent Orchestrator (this workshop)

Main agent reads lead, decides which sub-agents to spawn. Adaptive fan-out. Different leads get different depth.