---
theme: seriph
title: "Lesson 16 — When Should an Agent Ask for Help or Delegate?"
info: "English video course for AI Agents in Depth"
author: Bojie Li
transition: slide-left
mdc: true
lineNumbers: false
monaco: false
aspectRatio: 16/9
canvasWidth: 980
layout: cover
class: cover
---
Build · Chapter 4 · Tools
# When Should an Agent Ask for Help or Delegate?
Sub-agents, Human-in-the-Loop, and communication tools
Lesson 16 of 42 · 18 minutes · Collaboration Tools; User Communication; Virtual Identity
---
layout: center
class: text-center
---
The central question
How should an Agent hand work to another actor without losing context or control?
---
# Why this problem matters
Handoff
Pass only the facts and artifacts the collaborator needs.
Lifecycle
Spawn, message, query, cancel, and collect results.
Escalation
Ask a human when authority or missing judgment requires it.
---
# Three ideas to keep in view
Minimal handoff
Task parameters with almost no history
Distilled handoff
Facts, constraints, artifacts, and open questions
HITL
A permission and information channel—not an error screen
---
# The book's visual model
Event-driven asynchronous Agent architecture
---
# Full transcript vs. Handoff package
Full transcript
- Maximum context
- Large and biasing
- Leaks irrelevant information
Handoff package
- Confirmed facts
- Artifact paths
- Explicit responsibility
Context sharing and delegation are separate design decisions.
---
# Lifecycle primitives stay small
~~~python
worker = spawn_subagent(task, context=handoff)
send_message(worker, update)
status = get_status(worker)
if no_longer_needed(status):
cancel_subagent(worker)
~~~
---
# Test the claim
4-4A2 min
Compare sub-agent handoff strategies
Observe: Context size, task completeness, and irrelevant carryover
4-4B1 min
Exercise a Human-in-the-Loop gate
Observe: Pending state, timeout, approval, and audit record
Demo budget: 3 minutes · one contiguous terminal block
---
class: course-terminal
---
Live demo
# Switching to the terminal
~~~bash
$ uv run python chapter4/collaboration-tools/main.py subagent compare
$ uv run python chapter4/collaboration-tools/main.py hitl approve --message "Delete 1000 records?" --timeout 5 --auto-approve
~~~
Run the command(s), narrate decisions, and point to the observation—not just the output.
---
# What the evidence supports
Finding 1
A collaborator should receive a task contract, not indiscriminate history.
Finding 2
Cancellation and status are first-class parts of delegation.
Finding 3
Human intervention works best when the Agent explains the decision and safe defaults.
---
layout: center
---
Where the claim stops
# Boundary condition
A slow or unavailable human cannot be treated as a synchronous function call.
---
layout: center
---
Engineering takeaway
# Design rule
Design collaboration as an asynchronous lifecycle with explicit authority and structured handoffs.
---
# Continue the experiment
---
layout: center
class: text-center
---
Pause and apply
# Your turn
What should the Agent do safely while waiting for a user's decision?
---
layout: center
class: text-center
---
Next · Lesson 17
Allow events to arrive while the Agent is already working.
→