Part 6 · Inside a Production Coding Agent

Four Isolation Dimensions of Sub-Agents

Analyzing isolation boundaries across context source, recovery mode, worktree, and task state

THE QUESTION THIS PAGE ANSWERS

ANSWER FIRST

What is the key idea behind “Four Isolation Dimensions of Sub-Agents”?

Analyzing isolation boundaries across context source, recovery mode, worktree, and task state

DECISION RULE

Make the claim earn its place. Use this page as a decision aid, not a definition to memorize. Connect the idea to one real task, one observable result, and one failure that would change your mind.

TRY NEXT

Write one question you could answer with evidence after trying this idea.

WATCH FOR

A conclusion that sounds complete but leaves the key assumption untested.

Learning Objective

Be able to accurately explain ContextSource::New / ResumedResumeSourceDataSubagentIsolationMode, and select new sessions, resumption, and worktrees based on the task.

TEACHING DIAGRAM

Isolation is a Set of Orthogonal Dimensions

The same Resumed sub-agent can reuse a worktree or inherit the ordinary cwd. Context continuity and file-space isolation must be evaluated independently.

Four isolation dimensions: context, identity, working directory, and change scope childsession ContextSourceNew / Resumed Identitytype / persona / model pin Effective cwdworktree > override > parent Isolation modeNone / Worktree
Public Semantics of ContextSource

ContextSource::New

A new session does not inherit history. The spawn process establishes a new system prompt and prompt context, then receives the current task input. It does not imply an independent file space — that still depends on isolation and cwd.

ContextSource::Resumed

Continues from a completed peer subagent. Source code copies the original transcript and tool state; the model reuses the source model. System prompt and prompt context are re-rendered according to the current AgentDefinition.

Implementation Note: xai-grok-subagent-resolution::ContextSource The public enum has only New and Resumed. Internally, the shell also has InitialContextSource::Forked, used to mirror or summarize context from the parent session. It belongs to a different bootstrap branch and should not be presented as a public enum member.
ResumeSourceData Carries Resumption Location Information
Identitysubagent_id, type, persona, model_id
Directorychild_cwd, worktree_path
Session Datachild_session_id locates transcript and tool state
Snapshotsnapshot_ref can reconstruct a deleted worktree

Identity Validation

  • subagent_type must match the source.
  • An explicit Persona must match the source; if not explicitly provided, the source persona is inherited.
  • model is not part of the identity gate. A model override in the request is soft-ignored and pinned to the source model.

Resumption Constraints

  • If copying the transcript or reading it fails, an explicit resume will fail and close.
  • Resumption is rejected if the source transcript exceeds 80% of the target model's context window.
  • Resumption copies tool state but not plan state, plan mode state, or signals.
SubagentIsolationMode Has Only Two Variants

None

The sub-agent uses the resolved cwd, typically the same as the parent workspace. The context window is still an independent child session. None describes file workspace isolation — it does not mean shared conversation history.

Worktree

The sub-agent uses an independent worktree path. On resumption, the source worktree is reused first; if the path has been removed and a snapshot_ref exists, it can be rehydrated from the persistent git ref. This enum has no "sandbox" member.

crates/codegen/xai-grok-subagent-resolution/src/types.rs crates/codegen/xai-grok-subagent-resolution/src/resume.rs crates/common/xai-tool-types/src/task.rs bootstrap_initial_context resolve_child_cwd
Real Source Code Snapshot
crates/common/xai-tool-types/src/task.rsREAL SOURCE
pub enum SubagentIsolationMode {
    #[default]
    #[serde(alias = "None")]
    None,
    #[serde(alias = "Worktree", alias = "work_tree", alias = "work-tree")]
    Worktree,
}

Snapshot Note: The enum is fully preserved to show wire aliases. The concentric circles above are course visuals emphasizing dimension orthogonality — they do not represent object hierarchy in the source code.

Classroom Exercise: Choose Boundaries for Two Tasks

Task A needs to continue a half-finished refactor from yesterday and keep the original worktree's uncommitted changes. Task B only needs to independently analyze the current repository. For each, choose New or Resumed and None or Worktree, and explain how transcript, model, cwd, and file change scope are handled.

Takeaway: New and Resumed control information continuity; None and Worktree control file space; ResumeSourceData handles locating identity, directory, session, and snapshot. Decompose dimensions first, then discuss isolation strength.

Why “Isolation is a Set of Orthogonal Dimensions” depends on the operation

“Be able to accurately explain ContextSource::New / Resumed 、 ResumeSourceData 、 SubagentIsolationMode , and select new sessions, resumption, and worktrees based on the task” makes the structure concrete. The useful comparison is not which name sounds more advanced, but how the data is arranged and how far the most common operation has to travel.

Read a structure through access and change

“The same Resumed sub-agent can reuse a worktree or inherit the ordinary cwd.” exposes a trade-off that is easy to miss: reading by position, looking up by key, adding at either end, inserting in the middle, and traversing relationships do not favor the same organization. A structure that is fast for one operation is not automatically fast for all of them.

  • subagent_type must match the source
  • An explicit Persona must match the source; if not explicitly provided, the source persona is inherited
  • model is not part of the identity gate. A model override in the request is soft-ignored and pinned to the source model

Count scale and update frequency together

Use “Task A needs to continue a half-finished refactor from yesterday and keep the original worktree's uncommitted changes.” as a boundary check. Write down the data size, the dominant operation, and the latency you can accept before deciding whether an AI-generated structure actually fits.

From “Isolation is a Set of Orthogonal Dimensions” to “ContextSource::New”

“Isolation is a Set of Orthogonal Dimensions” grounds the problem in “The same Resumed sub-agent can reuse a worktree or inherit the ordinary cwd. Context continuity and file-space isolation must be evaluated independently”. “ContextSource::New” then moves it toward “A new session does not inherit history. The spawn process establishes a new system prompt and prompt context, then receives the current task input. It does not imply an independent file space — that still depen…”. Together, they show that the lesson is not just a conclusion to remember, but a claim with conditions.

Carry the judgment into the next situation

When you meet a new data structure, do not begin by memorizing its definition. Write down the most frequent operation, estimate scale and update behavior, and check whether the structure satisfies all three conditions.

  • “Isolation is a Set of Orthogonal Dimensions”: The same Resumed sub-agent can reuse a worktree or inherit the ordinary cwd. Context continuity and file-space isolation must be evaluated independently
  • “ContextSource::New”: A new session does not inherit history. The spawn process establishes a new system prompt and prompt context, then receives the current task input. It does not imply an independent file space — that still depen…
  • “The closing point”: Resumption is rejected if the source transcript exceeds 80% of the target model's context window

The final “The closing point” brings the discussion to “Resumption is rejected if the source transcript exceeds 80% of the target model's context window”. The useful thing to carry forward is knowing which judgments must be revisited when input, scale, or risk changes.

Mark as learned Your reading progress updates automatically
← PreviousNext →

Keep reading

The next useful article in the thread.

ARTICLE DISCUSSION

Leave one useful thought here.

Keep the idea that clicked, the question that stayed open, or a small note for the next learner.

Discussing Four Isolation Dimensions of Sub-Agents Inside a Production Coding Agent
3discussionsArticle discussion · synced with the Circle
View in the learning circle
AM
Asha MorganContent editor
INSIGHTField note

I turned one judgment from this article into a small experiment I could run today. Knowing what to observe next is more useful than simply remembering the conclusion.

ARTICLE DISCUSSION7 helpful
LH
Lin HarperIndie developer
INSIGHTInsight

After reading this, I first looked for the conditions behind the idea instead of copying the method into a project. That order made the later trade-offs much clearer.

ARTICLE DISCUSSION5 helpful
KM
Kiki MooreProduct operations
QUESTIONQuestion

When this judgment reaches real work, which constraint should be added first? I am curious which step matters most between reading and the first practical attempt.

ARTICLE DISCUSSION4 helpful