---
theme: seriph
title: "Lesson 39 — When Should Agents Share the Same Context?"
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
---
Expand · Chapter 10 · Multi-Agent Collaboration
# When Should Agents Share the Same Context?
Shared trajectories, isolated contexts, role switching, and handoffs
Lesson 39 of 42 · 17 minutes · Classification Framework; Shared vs. Non-Shared Context; Multi-Stage Role Switching
---
Expand · Chapter 10 · Multi-Agent Collaboration
# Problems this chapter will solve
Lesson 39
When Should Agents Share the Same Context?
Lesson 40
Who Should Coordinate Independent Agents?
Lesson 41
When Is Multi-Agent Actually Better Than One Agent?
Lesson 42
How Do Agent Teams Fail—and What Should We Build Next?
---
# Why this problem matters
Continuity
Shared history preserves details and user decisions.
Isolation
Separate contexts reduce interference and permission leakage.
Scale
Independent contexts enable parallel work beyond one window.
---
# Three ideas to keep in view
Shared context
New prompt/tools, same complete trajectory
Non-shared context
Independent trajectory + explicit communication
IPC analogy
Files as shared memory; calls/messages as message passing
---
# The book's visual model
Shared-context and non-shared-context multi-Agent architectures
---
# Shared context vs. Non-shared context
Shared context
- Near-zero handoff loss
- Mostly serial roles
- History grows and biases
Non-shared context
- Modular and parallel
- Selective disclosure
- Handoff can omit evidence
Share when loss is unacceptable; isolate when scale, focus, or security dominates.
---
# A role is prompt + tools + visible state
~~~python
stage = router.choose(task_state)
agent = Agent(prompt=stage.prompt, tools=stage.tools)
if stage.shared:
agent.resume(full_trajectory)
else: agent.start(handoff_package)
~~~
---
# Test the claim
10-11 min
Inspect staged prompts, tools, and fallback gates
Observe: Requirements, implementation, review, and revision boundaries
10-21 min
Inspect role-specific handoff capabilities
Observe: Distinct prompts, tools, transfer edges, and shared session state
Demo budget: 2 minutes · one contiguous terminal block
---
class: course-terminal
---
Live demo
# Switching to the terminal
~~~bash
$ cd chapter10/staged-system-prompt && python demo.py --list-stages
$ cd chapter10/multi-role-transfer && python demo.py --list-roles
~~~
Run the command(s), narrate decisions, and point to the observation—not just the output.
---
# What the evidence supports
Finding 1
Changing prompt and tools can create a specialist while preserving one trajectory.
Finding 2
Shared context removes handoff compression but can carry framing bias across roles.
Finding 3
Independent Agents require an explicit data plane and control plane.
---
layout: center
---
Where the claim stops
# Boundary condition
Calling predefined stages 'multi-Agent' is useful architecturally, but the execution remains a workflow with a known path.
---
layout: center
---
Engineering takeaway
# Design rule
Choose context sharing before topology: it determines information loss, isolation, parallelism, and token growth.
---
# Continue the experiment
---
layout: center
class: text-center
---
Pause and apply
# Your turn
Which detail would be too dangerous to omit from a handoff—and which detail should not cross the boundary?
---
layout: center
class: text-center
---
Next · Lesson 40
Choose who coordinates independent Agents and how artifacts and messages move between them.
→