Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
7.4 KiB
7.4 KiB
theme, title, info, author, transition, mdc, lineNumbers, monaco, aspectRatio, canvasWidth, layout, class
| theme | title | info | author | transition | mdc | lineNumbers | monaco | aspectRatio | canvasWidth | layout | class |
|---|---|---|---|---|---|---|---|---|---|---|---|
| seriph | Lesson 16 — When Should an Agent Ask for Help or Delegate? | English video course for AI Agents in Depth | Bojie Li | slide-left | true | false | false | 16/9 | 980 | cover | 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
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
$ 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
Multi-channel notifications
chapter4/collaboration-tools/
Timers and delayed tasks
chapter4/collaboration-tools/
Sub-agent comparison script
chapter4/collaboration-tools/subagent_comparison.py
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.
→