Context Isolation via Orchestrator-Worker Architectures
Explore how to split a multi-stage incident review across isolated workers instead of one growing conversation. Compare flat prompts, labeled sections, and true context isolation; measure token growth; and coordinate workers through concise results and focused handoffs.
We'll cover the following...
So far, the on-call assistant has been one agent in one conversation. In Chapter 5, we gave it tools to keep that conversation small: pruning, compaction, notes, and memory. But some tasks need several kinds of work, one after another. After the incident, someone has to write the incident review. That means planning it, gathering evidence, computing the impact from the metrics, checking the numbers, writing the review, and checking its citations.
If one agent does all of that in one conversation, everything it reads and produces stays in its context until the end. In this lesson, we’ll measure that growth, see why labeling sections inside one prompt doesn’t help, and then split the work across isolated workers: separate calls that each see only what they need and return a short result to a coordinator.
One agent, five stages
Let’s start with the data the review needs. We have per-minute checkout metrics from 14:00 to 14:19, and a service-level objective (SLO): checkout p99 latency must stay under one second.
In the code above:
Lines 1–3: We store p99 latency and requests for each minute from 14:00 to 14:19.
Line 4: We set the SLO at 1,000 ms.
Lines 7–12: We define
minute_label()andmetrics_table(), which turn the lists into one line per minute.
The spike starts at 14:05 and ends after 14:11:
14:00 p99=182 ms requests=121014:01 p99=176 ms requests=119514:02 p99=190 ms requests=123014:03 p99=185 ms requests=122014:04 p99=179 ms requests=120514:05 p99=2400 ms requests=115014:06 p99=2550 ms requests=112014:07 p99=2600 ms requests=110014:08 p99=2480 ms requests=113514:09 p99=2390 ms requests=116014:10 p99=2310 ms requests=117014:11 p99=2350 ms requests=118014:12 p99=640 ms requests=119014:13 p99=210 ms requests=120014:14 p99=205 ms requests=121514:15 p99=198 ms requests=122514:16 p99=201 ms requests=121014:17 p99=195 ms requests=120014:18 p99=190 ms requests=119514:19 p99=188 ms requests=1205
Now let’s write the first three stages of the review. Each stage returns two things: its full output, everything it read or produced, and a short result, the one line the next stage actually needs.
Here’s what each stage does: