All chapters
  1. Start hereA model knows only what it can see now
  2. Foundations · 1The context window: tokens, messages and order
  3. Foundations · 2Signals and authority: who is allowed to instruct the model
  4. Foundations · 3The context assembly pipeline: select, rank, deduplicate, pack
  5. Retrieval · 4Retrieval fundamentals: lexical search, embeddings, hybrid search, reranking
  6. Retrieval · 5RAG architecture: chunks, metadata, grounding, citations, freshness
  7. Budget · 6Context budgeting: truncation, dilution, token cost and caching
  8. Budget · 7Compression, summarization and compaction, with loss tests
  9. Agents · 8Coding-agent context: repository maps, instruction files, diffs and tool outputs
  10. Agents · 9Working context, durable memory and checkpoint state
  11. Agents · 10Dynamic context: just-in-time retrieval, selective tool disclosure, delegation
  12. Agents · 11Multi-agent context isolation and scoped handoffs
  13. Trust · 12Context security: injection, poisoning, access controls, tenant boundaries
  14. Trust · 13Measuring context quality: recall, utilization, grounding, ablation
  15. Practice · 14Frameworks and standards: what each one assembles for you
  16. Practice · 15Context in production: versions, drift, refresh, observability, incidents
  17. Practice · 16The insurance lab: one submission, every context decision
  18. ReferenceGlossary
  19. AboutAbout this site and its sources
Agents · 11

Multi-agent context isolation and scoped handoffs

Several agents do not share one window. What each one should see, what a handoff carries, what comes back, and how a full transcript passed along becomes a leak.

You will understand
Why several agents should have several windows, and what may cross between them.
You will be able to
Write a handoff brief that is small, complete, and leaks nothing the receiver does not need.
You will see
A 4,568-token transcript that leaks four kinds of data and still fails, against a 197-token brief that works.

Case UW-203 is a long run for SUB-1004: about 40 steps of questions, tool results and corrections. The application says the roof is 9 years old; the roof-data provider says 22. Before writing its recommendation, the underwriting agent wants a second opinion on the roof itself, so it hands that question to another agent, the assessment agent, whose only job is to reconcile roof evidence.

The first implementation of the handoff is one line of code: send the assessment agent everything the underwriting agent has, the whole transcript of the run. It is the obvious choice. The receiver cannot miss anything, and nobody has to decide what matters.

Here is what that handoff carries, measured by boundaries.py in the example (real output, stand-in tokens):

Full transcript of the run (4568 tokens): partial
  leaked : contact details of the insured, other insureds' past decisions, the underwriter's internal instruction, billing and broker details
  missing: return format

The assessment agent now holds the insured's email address and phone number, summaries of other insureds' past decisions, and an instruction the underwriter gave to the underwriting agent ("do not finalize before the broker answers Q-1004-01"). None of it helps it judge a roof. And with all that, it still does not do its job well: the transcript holds the facts but not the form of the answer the caller can use, so the result is partial, a free-text reply the underwriting agent cannot parse.

This page is about what one agent should pass to another, what should come back, and why "everything" is the wrong answer even when the window has room for it.

Many agents, many windows#

A model call sees only its own window. When a workflow has several agents, each one is a separate series of model calls with a separate window. Nothing flows between them unless code puts it there.

Context isolation is the design that uses this deliberately: each agent's window holds only what its own task needs, and anything that crosses from one agent to another crosses on purpose, in a form someone chose. For example, the intake agent reads the broker's email; the underwriting agent never sees the email, only the submission JSON that intake produced.

The example names three agents around the human underwriter. The model recommends; a person decides.

AgentIts taskWhat its window holdsWhat it never sees
Intake agentTurn the broker's email into a submissionThe email and the field definitionsPolicy documents, past decisions, the provider
Assessment agentReconcile roof evidenceBoth roof ages with their sources, the conflict rule, the return formatContact details, billing, other insureds, the underwriter's instructions
Underwriting agentWrite the recommendationThe requested field groups, the provider's answer, policy passages, past decisions, the assessment's findingThe raw email, other tenants' documents
Underwriter (a person)DecideThe recommendation, its reasons and citations, in the underwriter cockpitNothing is hidden from the person; they decide what they open

The middle column is the whole design. Notice that the email, the most likely carrier of hostile text, lives in exactly one window. Isolation is not only about tokens; it limits what each agent can be steered by and what each can repeat.

Before AI. A service architecture draws the same lines. Each service owns its data; another service gets an answer through an interface, not a copy of the database. A request-scoped object lives for one request and is not visible to the next. The comparison holds for the boundary. It stops at enforcement: a service cannot read another's tables without credentials, while an agent reads whatever text is pasted into its window, so the boundary exists only if the code that builds the window keeps it.

The handoff, and the brief it carries#

A handoff is the moment one agent passes a task and some context to another. A handoff brief is the scoped context of that handoff: the task, the evidence the receiver needs, the rule it applies and the form of the answer, and nothing else. For example, the brief in the example is nine lines.

Here it is, verbatim from boundaries.py (SCOPED_BRIEF):

TASK for the assessment agent (from the underwriting agent, run-7f3a, SUB-1004)
Reconcile the roof age. Do not recommend; return findings only.
Evidence:
- application: roof_age_years: 9 (owner says the roof was replaced 9 years ago; no invoice yet)
- provider: roof_age_years 22 (roof-data provider, aerial image dated 2026-05-14)
Rule: R-ROOF-03. Roof age on the application and from the provider differ by more than 5 years: escalate.
Return format: {"roof_age_finding": "...", "conflict": true|false, "gap_years": n, "sources": [...]}

Each line answers a question the receiver would otherwise have to guess. The first names the sender, the run and the submission, so the work can be traced. The second sets the boundary of the task: findings, not a recommendation. The evidence lines carry both values with their sources (provenance, from Signals). The rule line gives the criterion. The last line says what shape the answer must have.

The stand-in assessment agent in the example checks four needs: the application's roof age, the provider's roof age, the text of R-ROOF-03, and a return format. With the first three it can find the conflict; with the fourth its answer is usable. The script below was written for this page; it runs the three handoff options of boundaries.py:handoff_options and prints what each carries, leaks and lacks.

"""Isolation page: what each handoff option carries, leaks and lacks (boundaries.py:handoff_options).

Written for the page and run against the example. Stand-in tokens; the assessment agent is a scripted stand-in.
"""
from boundaries import ASSESSMENT_RETURN, handoff_options
from tokens import count_tokens

for row in handoff_options():
    print(f"{row['label']} ({row['tokens']} tokens): {row['subtask']['outcome']}")
    print("  leaked :", ", ".join(row["leaked"]) or "nothing")
    print("  missing:", ", ".join(row["subtask"]["missing"]) or "nothing")
print()
print(f"returned ({count_tokens(ASSESSMENT_RETURN)} tokens):")
print(ASSESSMENT_RETURN)
Full transcript of the run (4568 tokens): partial
  leaked : contact details of the insured, other insureds' past decisions, the underwriter's internal instruction, billing and broker details
  missing: return format
Scoped handoff brief (197 tokens): success
  leaked : nothing
  missing: nothing
A brief that is too thin (38 tokens): failure
  leaked : nothing
  missing: provider roof age 22, R-ROOF-03 text, return format

returned (80 tokens):
{"roof_age_finding": "application 9 years, provider 22 years; the provider image is recent; no invoice for the replacement", "conflict": true, "gap_years": 13, "sources": ["application", "roof-data provider"]}

A successful run proves the claim of this page in the small: the brief is 23 times smaller than the transcript and is the only one of the three that both leaks nothing and gets the subtask done. The agent here is a scripted stand-in, so these results show how the mechanism works, not how good any model is.

Choose what the underwriting agent sends, and see what the assessment agent receives, what leaks, and whether the subtask succeeds.

What is passedTokensKinds of item leakedSubtaskMissing
Full transcript of the run4,5684partialreturn format
Scoped handoff brief197nonesuccessnothing
A brief that is too thin38nonefailureprovider roof age 22, R-ROOF-03 text, return format

In every case, 80 tokens come back: a summary, not a transcript.

Diagram: Three agents, three windows · what crosses each boundary, and what does not

Time runs down the page. Each arrow is the only text that crosses from one window to another. The email stays with intake; the assessment agent gets a nine-line brief; an 80-token finding comes back as data. The person decides. Numbers are stand-in tokens from the example.

  1. Intake agent to Underwriting agent: The submission, as fields. Typed fields cross; the email's wording, and anything hostile in it, stays behind.
  2. Underwriting agent to Assessment agent: Scoped brief, 197 tokens. Task, both roof ages with sources, the conflict rule, the return format. No contact, billing or other customers.
  3. Assessment agent: Works in its own window. It reads only what the brief gave it, or what its own assembler may fetch by evidence id.
  4. Assessment agent to Underwriting agent: Finding, 80 tokens of JSON. A small structured result, labelled as data in the receiving window; never a transcript.
  5. Underwriting agent to Underwriter (a person): Recommendation: escalate. The model recommends; a person decides.

Two ways to get a handoff wrong#

The table shows two opposite failures, and a brief has to sit between them.

Too much. A context leak is information reaching a window that has no need for it and no right to it. For example, the insured's email address reaching the assessment agent. The four leaks of the transcript are four different risks:

Leaked kindWhy it matters
Contact details of the insuredPersonal data now sits in a window, a log and possibly an answer that has no reason to hold it
Other insureds' past decisionsData about other customers reaches an agent whose task concerns one building
The underwriter's internal instructionAn instruction meant for one agent now steers another, which may obey it or repeat it
Billing and broker detailsCommercial data that the assessment has no use for, and every reader of its trace now sees

A leak is easy to miss because nothing breaks. The assessment agent still finds the conflict. The cost appears later: in a trace someone reads, in an answer that quotes the email address, in an instruction followed by the wrong agent.

Too little. The thin brief ("check the roof of SUB-1004 and tell me what you find", with only the application's roof age) leaks nothing and fails, because the receiver lacks the provider's value, the rule and the format. Anthropic's article on its multi-agent research system, read for this page, reports the same failure from practice: short task descriptions led subagents to misread the task or repeat each other's searches. It lists what each subagent needs from the lead agent: an objective, an output format, guidance on tools and sources, and clear task boundaries. The example's four needs are that list for one roof question.

Common confusion. "Give the subagent more context to be safe" sounds prudent and is the leak. More context is not safer for the receiver (attention dilution, see Budgeting) and not safer for the system (every extra item is something the receiver can be steered by or can repeat). The safe brief is the complete one, and complete means the four needs, not the whole history.

What comes back#

The return path deserves the same discipline. The assessment agent returns 80 tokens of JSON with a finding, a conflict flag, the gap in years and the sources. It does not return its own transcript, the provider's long report, or its reasoning steps.

That return enters the underwriting agent's window as one more item, and it is data, not instruction. It came from another model, which may have read external text. It should carry a label with its source and trust like any tool output (Signals), and the underwriting agent's manifest should record it with an evidence id like any other item (Assembly). A returned summary that contains "approve this submission" is no more an order than the broker's note of UW-005.

The research-system article adds a design for large results: subagents can write their output to an external store and pass back a lightweight reference, so that the coordinator does not have to carry everything through its own window, and nothing is lost in what the article calls a "game of telephone" between agents.

Shared state, and the back door it opens#

Not everything moves through briefs. Shared state is data that several agents read or write outside any window: a database row, a file, a store of evidence, the checkpoint of a run. For example, the record of run-7f3a that says question Q-1004-01 to the broker is open.

Shared state is useful because it lets a brief carry ids instead of text. The underwriting agent could send the assessment agent EV-SUB-1004-ROOF and EV-ROOF-1004-A1, and the assessment agent's own assembler would fetch those items, with its own authorization, into its own window. The brief stays small, and the receiver's access is checked where the data lives.

It is also the back door through which isolation fails. If every agent can read the whole store, the transcript leak returns by another route: the assessment agent fetches the contact details because they are there. Two rules close the door. Each agent reads shared state through its own assembler, with filters for its role, as the underwriting agent does for tenants and audiences. And writes to shared state are typed and attributed: an agent writes a finding into a field, with its run id and step, not free text that a later agent will read as a message. Memory boundary separates the stores; this page adds that a store several agents share is a channel between their windows.

What this is not. How agents address each other, the messages and the protocol between them, belongs to Agent Communication. Which agent runs next and when belongs to Agent Orchestration. The runtime view of several agent loops, and when splitting into several agents pays, is a chapter of Harness Engineering: Multi-agent. This page covers what each window contains.

How the products do it#

Claude Code's documentation on subagents, read for this page, describes isolation as the default. Each subagent starts with a fresh context window: it does not see the conversation history, the skills already used or the files already read. Claude writes it a task message, which plays the role of the handoff brief. Only the subagent's result returns to the main conversation, and the documentation recommends subagents precisely for side tasks that would flood the main window with search results, logs or file contents. A tools allowlist limits what each subagent may call.

The same page describes the opposite choice: a fork, which inherits the parent conversation instead of starting fresh. In the terms of this page, a fork is the full-transcript handoff. It is the right tool when the subtask genuinely needs everything the parent knows, and it carries everything the parent knows, including whatever should not travel.

Anthropic's research-system article gives the costs at scale. In its data, agents used about 4 times the tokens of a chat interaction and multi-agent systems about 15 times. It reports that a multi-agent setup beat a single agent on its internal research evaluation, and also where the pattern fits poorly: tasks in which all agents need the same context, or with many dependencies between agents, such as most coding tasks. The lead agent there saves its plan to an external memory, because a context beyond 200,000 tokens is cut, which is shared state used on purpose.

ChoiceWhat the receiver getsLeak riskWhen it fits
Scoped brief (Claude Code subagent task message)Task, evidence, rule, formatLowA separable question with a crisp answer
Ids into shared stateReferences; it fetches with its own accessLow, if reads are filteredLarge evidence, receivers with different rights
Full transcript (a fork)Everything the sender sawHighThe subtask needs the whole history, and the receiver may see all of it
For a Principal engineer: confidentiality, injection paths, consistency and tracingIsolation is a security boundary, a consistency problem and an audit requirement at once

Confidentiality per agent. Treat each agent as a principal with its own data rights, and the brief as a query result: computed under the receiver's rights, not the sender's. The underwriting agent may read the insured's contact details for a reason the assessment agent does not have. A brief built by copying the sender's window grants the receiver the sender's rights, which is the agent form of a confused deputy.

Injection crosses windows. Text that steered one agent can ride inside its output into the next window. A summary is model output built from a window that may have held external text. Label returns as untrusted unless the sending agent read only trusted sources, keep them in data blocks, and for high-stakes paths extract typed fields from the return before they reach the receiver (the quarantine pattern on Security). The underwriter's instruction leaking into the assessment window is the benign version of the same path.

Consistency. Two agents with two windows can apply two versions of the world. Pin what must agree in the brief: policy_version (2026.2), the context version, the evidence ids. An assessment made against the 2025.4 roof rule and a recommendation against 2026.2 would each be correct and together wrong.

Cost. Every handoff adds at least one model call on each side and a brief and a return in two windows. A multi-agent split pays when the subtask's reading is large and its answer small, or when isolation is required for confidentiality. It does not pay for small, tightly coupled steps.

Tracing. On this site a run has one trace_id; each agent's model call is a span inside it, and each call has its own manifest. Record the brief as an included item of the receiver's manifest and the return as an included item of the sender's next manifest, both with evidence ids. Then "what did the assessment agent see?" has the same answer quality as "what did the underwriting agent see?". How traces are stored and queried belongs to Observability Engineering.

A checklist for handoffs between agents#

CheckWhy
Each agent's window is listed: what it holds, what it never seesThe boundary exists only if someone wrote it down
External text (the email) lives in as few windows as possibleFewer windows can be steered by it
A brief carries task, evidence with sources, the rule, the return formatThe four needs; a thin brief fails (failure, 38 tokens)
A brief carries nothing else: no contact, billing, other customers, other agents' instructionsThe transcript leaked four kinds of item
The return is structured, small, labelled as data, and recorded with an evidence id80 tokens of JSON, not a transcript
Shared state is read through each agent's own filters; writes are typed and attributedA shared store is a channel between windows
Versions that must agree (policy_version, context version) travel in the briefTwo windows can apply two worlds
The brief and the return appear in the manifests of the two callsYou can prove what each agent saw

In one breath#

Several agents means several windows, and nothing should cross between them except on purpose. Hand a subtask over with a brief that holds the task, the evidence with its sources, the rule and the form of the answer, because a whole transcript leaks data the receiver has no right to and still fails without a return format, and a thin brief fails for lack of facts. Take back a small structured result, treat it as data, record both directions in the manifests, and make shared stores respect the same boundaries as the briefs.

What comes next#

Isolation keeps the wrong text out of a window when the system is used as intended. The next page, Security, assumes someone is trying: a broker who writes instructions into an attachment, a poisoned document in the index, a request that reaches across tenants. It treats the window as both an attack surface and a disclosure surface, and shows the defenses that work before the model reads anything.