@xzzpig/pi-subagents 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,7 +28,7 @@ import { backgroundProcessOptions } from "../shared/background-process-options.t
28
28
  import { buildSkillInjection, normalizeSkillInput, resolveSkillsWithFallback } from "../../agents/skills.ts";
29
29
  import { buildAgentMemoryInjection } from "../../agents/agent-memory.ts";
30
30
  import { PI_CODING_AGENT_PACKAGE_ROOT_ENV, PROMPT_REDACTED, resolveChildCwd } from "../../shared/utils.ts";
31
- import { buildModelCandidates, resolveEffectiveSubagentModel, resolveModelOrigin, resolveSubagentModelOverride, type AvailableModelInfo, type ModelOrigin, type ParentModel } from "../shared/model-fallback.ts";
31
+ import { buildModelCandidates, inheritsParentModel, resolveEffectiveSubagentModel, resolveModelOrigin, resolveSubagentModelOverride, type AvailableModelInfo, type ModelOrigin, type ParentModel } from "../shared/model-fallback.ts";
32
32
  import { resolveToolTimeoutMs, toolTimeoutFromEnv } from "../shared/tool-timeout.ts";
33
33
  import { resolveModelScopesForAgent, type ModelScopeConfig } from "../shared/model-scope.ts";
34
34
  import { findModelInfo, resolveEffectiveThinking } from "../../shared/model-info.ts";
@@ -91,9 +91,14 @@ const piPackageRoot = resolvePiPackageRoot() ?? resolveInstalledPiPackageRoot();
91
91
  function resolveJitiCliFromPackageJson(packageJsonPath: string): string | undefined {
92
92
  if (!fs.existsSync(packageJsonPath)) return undefined;
93
93
  const packageRoot = path.dirname(packageJsonPath);
94
- const pkg = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8")) as {
95
- bin?: string | Record<string, string>;
96
- };
94
+ let parsed: unknown;
95
+ try {
96
+ parsed = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
97
+ } catch {
98
+ return undefined;
99
+ }
100
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return undefined;
101
+ const pkg = parsed as { bin?: string | Record<string, string> };
97
102
  const binField = pkg.bin;
98
103
  const binPath = typeof binField === "string"
99
104
  ? binField
@@ -146,6 +151,10 @@ interface AsyncExecutionContext {
146
151
  currentModel?: ParentModel;
147
152
  /** Optional model-scope enforcement resolved from subagent settings. */
148
153
  modelScope?: ModelScopeConfig;
154
+ /** Parent-authoritative trust state for profile-aware project config merging. */
155
+ projectTrusted?: boolean;
156
+ /** Exact trusted parent cwd; project config applies only when it matches the child cwd. */
157
+ trustedProjectCwd?: string;
149
158
  /** Whether the parent session has an interactive UI. */
150
159
  interactive?: boolean;
151
160
  /** The executor's own child runtime when the launch comes from an in-process child. */
@@ -223,6 +232,8 @@ interface AsyncSingleParams {
223
232
  agentConfig: AgentConfig;
224
233
  /** Agent contract before per-run bridge injection, used only for recovery persistence. */
225
234
  recoveryAgentConfig?: AgentConfig;
235
+ /** Selected global sandbox profile carried across revival. */
236
+ sandbox?: string;
226
237
  ctx: AsyncExecutionContext;
227
238
  cwd?: string;
228
239
  requestedCwd?: string;
@@ -375,9 +386,9 @@ export function isAsyncAvailable(): boolean {
375
386
  return jitiCliPath !== undefined;
376
387
  }
377
388
 
378
- export function resolveAsyncRunnerLogPaths(cfg: object): { stdoutPath: string; stderrPath: string } | undefined {
379
- const asyncDir = typeof (cfg as { asyncDir?: unknown }).asyncDir === "string"
380
- ? (cfg as { asyncDir: string }).asyncDir
389
+ export function resolveAsyncRunnerLogPaths(cfg: Record<string, unknown>): { stdoutPath: string; stderrPath: string } | undefined {
390
+ const asyncDir = typeof cfg.asyncDir === "string"
391
+ ? cfg.asyncDir
381
392
  : undefined;
382
393
  if (!asyncDir) return undefined;
383
394
  return {
@@ -537,7 +548,7 @@ export function emitProcessTerminalEvent(ctx: AsyncExecutionContext, proof: unkn
537
548
  }
538
549
  }
539
550
 
540
- function spawnRunner(cfg: object, suffix: string, cwd: string, initialStatus: Omit<AsyncStatus, "pid" | "processTerminal">, initialStatusPath: string, onProcessTerminal?: (proof: unknown) => void, onBeforeProceed?: (runnerProcessInstanceId: string) => void, requestedCwd = cwd): SpawnRunnerResult {
551
+ function spawnRunner(cfg: Record<string, unknown>, suffix: string, cwd: string, initialStatus: Omit<AsyncStatus, "pid" | "processTerminal">, initialStatusPath: string, onProcessTerminal?: (proof: unknown) => void, onBeforeProceed?: (runnerProcessInstanceId: string) => void, requestedCwd = cwd): SpawnRunnerResult {
541
552
  const cwdError = preflightLaunchCwd(requestedCwd, cwd);
542
553
  if (cwdError) return { error: cwdError };
543
554
 
@@ -753,6 +764,19 @@ const UNAVAILABLE_SUBAGENT_SKILL_ERROR = "Skills not found: pi-subagents";
753
764
  class UnavailableSubagentSkillError extends Error {}
754
765
  class AsyncStartValidationError extends Error {}
755
766
 
767
+ function profileProjectTrustedForCwd(ctx: AsyncExecutionContext, cwd: string): boolean {
768
+ return ctx.projectTrusted === true
769
+ && ctx.trustedProjectCwd !== undefined
770
+ && path.resolve(ctx.trustedProjectCwd) === path.resolve(cwd);
771
+ }
772
+
773
+ function profileProjectTrustError(agent: AgentConfig, ctx: AsyncExecutionContext, cwd: string): string {
774
+ if (ctx.projectTrusted !== true) {
775
+ return `Agent '${agent.name}' selects sandbox profile '${agent.sandbox}' from project scope, but the project is not trusted. Trust the project and retry.`;
776
+ }
777
+ return `Agent '${agent.name}' selects sandbox profile '${agent.sandbox}' from project scope, but the child cwd is not an exact trusted project root. Launch from that trusted cwd and retry.`;
778
+ }
779
+
756
780
  export function buildAsyncRunnerSteps(id: string, params: AsyncRunnerStepBuildParams): AsyncRunnerStepBuildResult {
757
781
  const {
758
782
  chain,
@@ -844,6 +868,7 @@ export function buildAsyncRunnerSteps(id: string, params: AsyncRunnerStepBuildPa
844
868
  if (s.outputSchema !== undefined) unsupported.push("structured output");
845
869
  if (s.acceptance !== undefined || params.agentContract !== undefined || s.agentContract !== undefined) unsupported.push("acceptance/agent contract");
846
870
  if (s.toolBudget !== undefined || params.toolBudget !== undefined || a.toolBudget !== undefined || params.configToolBudget !== undefined) unsupported.push("tool budget");
871
+ if (a.sandbox !== undefined) unsupported.push("sandbox profile");
847
872
  if ((s.fast ?? params.fast ?? a.fast) === true) unsupported.push("fast mode");
848
873
  if (params.contextForAgent?.(s.agent) === "fork") unsupported.push("fork context");
849
874
  if (unsupported.length > 0) throw new AsyncStartValidationError(`Agent '${a.name}' uses runner.type='${externalRunnerType}' and does not support: ${unsupported.join(", ")}.`);
@@ -878,6 +903,10 @@ export function buildAsyncRunnerSteps(id: string, params: AsyncRunnerStepBuildPa
878
903
  resolvedBehavior,
879
904
  });
880
905
  const { stepCwd, instructionCwd, readExistenceCwd, behavior, namespaceOutputPath, outputPath, skillNames } = launchPlan;
906
+ const profileChildCwd = behaviorCwd ?? stepCwd;
907
+ if (a.sandbox && (a.source === "project" || a.override?.scope === "project") && !profileProjectTrustedForCwd(ctx, profileChildCwd)) {
908
+ throw new AsyncStartValidationError(profileProjectTrustError(a, ctx, profileChildCwd));
909
+ }
881
910
  const { resolved: resolvedSkills, missing: missingSkills } = resolveSkillsWithFallback(
882
911
  skillNames,
883
912
  stepCwd,
@@ -977,6 +1006,7 @@ export function buildAsyncRunnerSteps(id: string, params: AsyncRunnerStepBuildPa
977
1006
  agentName: a.name,
978
1007
  permissionRules,
979
1008
  runtimeSnapshotHost: ctx.pi,
1009
+ sandbox: a.sandbox,
980
1010
  });
981
1011
  const launchResolvedExtensions = externalRunner ? undefined : projectLaunchResolvedChildExtensions(toolPlan);
982
1012
  if (externalRunner && permissionRules) {
@@ -999,6 +1029,8 @@ export function buildAsyncRunnerSteps(id: string, params: AsyncRunnerStepBuildPa
999
1029
  return {
1000
1030
  parentSessionId: ctx.parentSessionId ?? ctx.currentSessionId,
1001
1031
  permissionRules,
1032
+ ...(ctx.projectTrusted !== undefined ? { projectTrusted: ctx.projectTrusted } : {}),
1033
+ ...(ctx.trustedProjectCwd ? { trustedProjectCwd: ctx.trustedProjectCwd } : {}),
1002
1034
  ...(params.capabilityCeiling ? { capabilityCeiling: params.capabilityCeiling } : {}),
1003
1035
  ...(runFanoutPath ? { runFanoutPath } : {}),
1004
1036
  agent: s.agent,
@@ -1029,6 +1061,7 @@ export function buildAsyncRunnerSteps(id: string, params: AsyncRunnerStepBuildPa
1029
1061
  mcpDirectTools: a.mcpDirectTools,
1030
1062
  mutationTools: a.mutationTools,
1031
1063
  completionGuard: a.completionGuard,
1064
+ ...(a.sandbox ? { sandbox: a.sandbox } : {}),
1032
1065
  systemPrompt,
1033
1066
  systemPromptMode: a.systemPromptMode,
1034
1067
  inheritProjectContext: a.inheritProjectContext,
@@ -1585,6 +1618,7 @@ export function executeAsyncSingle(
1585
1618
  const externalRunner = agentConfig.runner?.type === "external-cli" || agentConfig.runner?.type === "external-job";
1586
1619
  const externalRunnerType = agentConfig.runner?.type;
1587
1620
  const permissionRules = resolvePermissionRules(ctx.permissions, agentConfig.permissions);
1621
+ const sandbox = params.sandbox ?? agentConfig.sandbox;
1588
1622
  if (externalRunner) {
1589
1623
  const unsupported: string[] = [];
1590
1624
  if (params.modelOverride !== undefined) unsupported.push("model override");
@@ -1593,6 +1627,7 @@ export function executeAsyncSingle(
1593
1627
  if (params.structuredOutputSchema !== undefined) unsupported.push("structured output");
1594
1628
  if (params.acceptance !== undefined || params.agentContract !== undefined) unsupported.push("acceptance/agent contract");
1595
1629
  if (params.toolBudget !== undefined || agentConfig.toolBudget !== undefined || params.configToolBudget !== undefined) unsupported.push("tool budget");
1630
+ if (sandbox !== undefined) unsupported.push("sandbox profile");
1596
1631
  if (params.context === "fork") unsupported.push("fork context");
1597
1632
  if ((params.skills?.length ?? 0) > 0) unsupported.push("skills");
1598
1633
  if (permissionRules) unsupported.push("native Pi child permissions");
@@ -1620,6 +1655,9 @@ export function executeAsyncSingle(
1620
1655
  : params.worktree === true && managedWorktreeProvider === "native"
1621
1656
  ? resolveExpectedWorktreeAgentCwd(runnerCwd, `${id}-s0`, 0, worktreeBaseDir)
1622
1657
  : runnerCwd;
1658
+ if (sandbox && (agentConfig.source === "project" || agentConfig.override?.scope === "project") && !profileProjectTrustedForCwd(ctx, instructionCwd)) {
1659
+ return formatAsyncStartError("single", profileProjectTrustError(agentConfig, ctx, instructionCwd));
1660
+ }
1623
1661
  const readExistenceCwd = params.worktree === true ? runnerCwd : instructionCwd;
1624
1662
  const skillNames = params.skills ?? agentConfig.skills ?? [];
1625
1663
  const availableModels = params.availableModels;
@@ -1772,6 +1810,7 @@ export function executeAsyncSingle(
1772
1810
  agentName: agentConfig.name,
1773
1811
  permissionRules: resolvePermissionRules(ctx.permissions, agentConfig.permissions),
1774
1812
  runtimeSnapshotHost: ctx.pi,
1813
+ sandbox,
1775
1814
  });
1776
1815
  const launchResolvedExtensions = externalRunner ? undefined : projectLaunchResolvedChildExtensions(toolPlan);
1777
1816
  if (!externalRunner) {
@@ -1801,6 +1840,7 @@ export function executeAsyncSingle(
1801
1840
  inheritProjectContext: agentConfig.inheritProjectContext,
1802
1841
  inheritGlobalContext: agentConfig.inheritGlobalContext,
1803
1842
  inheritSkills: agentConfig.inheritSkills,
1843
+ sandbox,
1804
1844
  skills: resolvedSkills.map((skill) => skill.name),
1805
1845
  tools: toolPlan.effectiveToolAllowlist,
1806
1846
  ...(toolPlan.excludeTools.length > 0 ? { excludeTools: toolPlan.excludeTools } : {}),
@@ -1830,6 +1870,7 @@ export function executeAsyncSingle(
1830
1870
  sourceRunId: id,
1831
1871
  ...(params.agentContract ? { agentContract: params.agentContract } : {}),
1832
1872
  agent,
1873
+ ...(sandbox ? { sandbox } : {}),
1833
1874
  launchResolvedExtensions,
1834
1875
  ...(sessionFile ? { sessionFile } : {}),
1835
1876
  cwd: runnerCwd,
@@ -1894,6 +1935,8 @@ export function executeAsyncSingle(
1894
1935
  {
1895
1936
  parentSessionId: ctx.parentSessionId ?? ctx.currentSessionId,
1896
1937
  permissionRules,
1938
+ ...(ctx.projectTrusted !== undefined ? { projectTrusted: ctx.projectTrusted } : {}),
1939
+ ...(ctx.trustedProjectCwd ? { trustedProjectCwd: ctx.trustedProjectCwd } : {}),
1897
1940
  ...(capabilityCeiling ? { capabilityCeiling } : {}),
1898
1941
  agent,
1899
1942
  task: taskText,
@@ -1918,6 +1961,7 @@ export function executeAsyncSingle(
1918
1961
  mcpDirectTools: agentConfig.mcpDirectTools,
1919
1962
  mutationTools: agentConfig.mutationTools,
1920
1963
  completionGuard: agentConfig.completionGuard,
1964
+ ...(sandbox ? { sandbox } : {}),
1921
1965
  systemPrompt,
1922
1966
  systemPromptMode: agentConfig.systemPromptMode,
1923
1967
  inheritProjectContext: agentConfig.inheritProjectContext,
@@ -2056,6 +2100,7 @@ export function executeAsyncSingle(
2056
2100
  mode: "single",
2057
2101
  state: "running",
2058
2102
  agent,
2103
+ ...(sandbox ? { sandbox } : {}),
2059
2104
  agents: [agent],
2060
2105
  chainStepCount: 1,
2061
2106
  ...(timeoutMs !== undefined ? { timeoutMs, deadlineAt } : {}),
@@ -2076,6 +2121,7 @@ export function executeAsyncSingle(
2076
2121
  completionOwnerId: ctx.completionOwnerId ?? currentCompletionOwnerId(),
2077
2122
  mode: "single",
2078
2123
  agent,
2124
+ ...(sandbox ? { sandbox } : {}),
2079
2125
  task: task?.trim() ? PROMPT_REDACTED : undefined,
2080
2126
  goal: (params.goal ?? task).trim() ? PROMPT_REDACTED : undefined,
2081
2127
  cwd: runnerCwd,
@@ -15,6 +15,7 @@ import { parallelHandoffPath, resolveRetainedWorktreeCwd } from "../shared/paral
15
15
  import { normalizeWorktreeBaseRef } from "../shared/worktree.ts";
16
16
  import { intersectThinkingCeilings, parseThinkingLevel, type ThinkingLevel } from "../../shared/thinking-ceiling.ts";
17
17
  import { assertWorkflowGraphHostSteps } from "../shared/host-step-status.ts";
18
+ import { validateSandboxProfileName } from "../../shared/sandbox-profile.ts";
18
19
 
19
20
  export interface AsyncResumeParams {
20
21
  id?: string;
@@ -55,6 +56,7 @@ export type AsyncResumeTarget = {
55
56
  recoveryDescriptor?: SteeringRecoveryDescriptor;
56
57
  capabilityCeiling?: ResolvedSubagentCapabilityCeiling;
57
58
  launchContractDigest?: string;
59
+ sandbox?: string;
58
60
  runner?: NonNullable<AsyncStatus["steps"]>[number]["runner"];
59
61
  externalJob?: NonNullable<AsyncStatus["steps"]>[number]["externalJob"];
60
62
  };
@@ -73,8 +75,9 @@ interface AsyncResultFile {
73
75
  model?: string;
74
76
  thinking?: string;
75
77
  launchContractDigest?: string;
78
+ sandbox?: string;
76
79
  capabilityCeiling?: ResolvedSubagentCapabilityCeiling;
77
- results?: Array<{ agent?: string; sessionName?: string; success?: boolean; sessionFile?: string; intercomTarget?: string; model?: string; thinking?: string; launchContractDigest?: string; capabilityCeiling?: ResolvedSubagentCapabilityCeiling }>;
80
+ results?: Array<{ agent?: string; sessionName?: string; success?: boolean; sessionFile?: string; intercomTarget?: string; model?: string; thinking?: string; launchContractDigest?: string; sandbox?: string; capabilityCeiling?: ResolvedSubagentCapabilityCeiling }>;
78
81
  }
79
82
 
80
83
  export interface AsyncRunLocation {
@@ -116,10 +119,13 @@ function validateResultFile(value: unknown, resultPath: string): AsyncResultFile
116
119
  const model = validateOptionalString(child, "model", resultPath, `results[${index}].model`);
117
120
  const thinking = validateOptionalString(child, "thinking", resultPath, `results[${index}].thinking`);
118
121
  const launchContractDigest = validateOptionalString(child, "launchContractDigest", resultPath, `results[${index}].launchContractDigest`);
122
+ const sandbox = child.sandbox === undefined
123
+ ? undefined
124
+ : validateSandboxProfileName(child.sandbox, `async result file '${resultPath}' results[${index}].sandbox`);
119
125
  const capabilityCeiling = child.capabilityCeiling === undefined ? undefined : parseSubagentCapabilityCeiling(child.capabilityCeiling, `async result file '${resultPath}' results[${index}].capabilityCeiling`);
120
126
  const success = child.success;
121
127
  if (success !== undefined && typeof success !== "boolean") throw new Error(`Invalid async result file '${resultPath}': results[${index}].success must be a boolean.`);
122
- return { agent, sessionName, sessionFile, intercomTarget, model, thinking, launchContractDigest, ...(capabilityCeiling ? { capabilityCeiling } : {}), ...(typeof success === "boolean" ? { success } : {}) };
128
+ return { agent, sessionName, sessionFile, intercomTarget, model, thinking, launchContractDigest, ...(sandbox ? { sandbox } : {}), ...(capabilityCeiling ? { capabilityCeiling } : {}), ...(typeof success === "boolean" ? { success } : {}) };
123
129
  });
124
130
  }
125
131
  const success = data.success;
@@ -136,6 +142,7 @@ function validateResultFile(value: unknown, resultPath: string): AsyncResultFile
136
142
  model: validateOptionalString(data, "model", resultPath),
137
143
  thinking: validateOptionalString(data, "thinking", resultPath),
138
144
  launchContractDigest: validateOptionalString(data, "launchContractDigest", resultPath),
145
+ ...(data.sandbox === undefined ? {} : { sandbox: validateSandboxProfileName(data.sandbox, `async result file '${resultPath}' sandbox`) }),
139
146
  ...(data.capabilityCeiling === undefined ? {} : { capabilityCeiling: parseSubagentCapabilityCeiling(data.capabilityCeiling, `async result file '${resultPath}' capabilityCeiling`) }),
140
147
  ...(typeof success === "boolean" ? { success } : {}),
141
148
  ...(results ? { results } : {}),
@@ -282,6 +289,7 @@ function validateStatusForResume(status: AsyncStatus | null, source: string): vo
282
289
  if (stepRecord.thinking !== undefined && typeof stepRecord.thinking !== "string") throw new Error(`Invalid async status '${source}': steps[${index}].thinking must be a string.`);
283
290
  if (stepRecord.thinkingCeiling !== undefined) stepRecord.thinkingCeiling = parseThinkingLevel(stepRecord.thinkingCeiling, `async status '${source}' steps[${index}].thinkingCeiling`);
284
291
  if (stepRecord.launchContractDigest !== undefined && typeof stepRecord.launchContractDigest !== "string") throw new Error(`Invalid async status '${source}': steps[${index}].launchContractDigest must be a string.`);
292
+ if (stepRecord.sandbox !== undefined) stepRecord.sandbox = validateSandboxProfileName(stepRecord.sandbox, `async status '${source}' steps[${index}].sandbox`);
285
293
  if (stepRecord.capabilityCeiling !== undefined) stepRecord.capabilityCeiling = parseSubagentCapabilityCeiling(stepRecord.capabilityCeiling, `async status '${source}' steps[${index}].capabilityCeiling`);
286
294
  });
287
295
  }
@@ -317,7 +325,7 @@ export function readAsyncRecoveryDescriptor(asyncDir: string | undefined): Steer
317
325
  if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`Invalid async recovery descriptor '${descriptorPath}': expected an object.`);
318
326
  const parsed = value as Record<string, unknown>;
319
327
  const allowedFields = new Set([
320
- "version", "launchContractDigest", "sourceRunId", "agentContract", "agent", "sessionFile", "cwd", "model", "modelProvider", "modelOverrideFromParent", "modelOrigin", "fallbackModels", "thinking", "thinkingCeiling", "tools", "allowNestedSubagents", "extensions",
328
+ "version", "launchContractDigest", "sourceRunId", "agentContract", "agent", "sandbox", "sessionFile", "cwd", "model", "modelProvider", "modelOverrideFromParent", "modelOrigin", "fallbackModels", "thinking", "thinkingCeiling", "tools", "allowNestedSubagents", "extensions",
321
329
  "subagentOnlyExtensions", "mcpDirectTools", "excludeTools", "mutationTools", "systemPrompt", "systemPromptMode", "inheritProjectContext", "inheritGlobalContext", "inheritSkills", "skills",
322
330
  "skillPath", "agentFilePath", "completionGuard", "memory", "outputPath", "outputMode", "structuredOutputSchema", "acceptance", "sessionDir", "artifactConfig",
323
331
  "artifactsDir", "maxOutput", "controlConfig", "context", "intercomBridge", "absoluteDeadlineAt", "initialTurnBudget", "initialToolBudget", "maxSubagentDepth", "share", "capabilityCeiling",
@@ -375,6 +383,7 @@ export function readAsyncRecoveryDescriptor(asyncDir: string | undefined): Steer
375
383
  throw new Error(`Invalid async recovery descriptor '${descriptorPath}': ${error instanceof Error ? error.message : String(error)}`);
376
384
  }
377
385
  }
386
+ if (parsed.sandbox !== undefined) parsed.sandbox = validateSandboxProfileName(parsed.sandbox, `async recovery descriptor '${descriptorPath}' sandbox`);
378
387
  if (parsed.completionGuard !== undefined && typeof parsed.completionGuard !== "boolean") throw new Error(`Invalid async recovery descriptor '${descriptorPath}': completionGuard must be a boolean.`);
379
388
  if (parsed.structuredOutputSchema !== undefined && (!parsed.structuredOutputSchema || typeof parsed.structuredOutputSchema !== "object" || Array.isArray(parsed.structuredOutputSchema))) throw new Error(`Invalid async recovery descriptor '${descriptorPath}': structuredOutputSchema must be an object.`);
380
389
  if (parsed.memory !== undefined) {
@@ -432,6 +441,8 @@ export function readAsyncRecoveryDescriptor(asyncDir: string | undefined): Steer
432
441
  if (!Array.isArray(control.notifyChannels) || control.notifyChannels.some((item) => item !== "event" && item !== "async" && item !== "intercom")) throw new Error(`Invalid async recovery descriptor '${descriptorPath}': controlConfig.notifyChannels is invalid.`);
433
442
  }
434
443
  if (parsed.acceptance !== undefined) parsed.acceptance = normalizeRecoveryAcceptance(parsed.acceptance, descriptorPath);
444
+ // SAFETY: every supported field above is validated and normalized before this
445
+ // object crosses the persisted JSON boundary into the recovery descriptor type.
435
446
  return parsed as unknown as SteeringRecoveryDescriptor;
436
447
  }
437
448
 
@@ -505,6 +516,7 @@ export function resolveAsyncResumeTarget(params: AsyncResumeParams, deps: AsyncR
505
516
  sessionFile: selectedStep.sessionFile ?? status?.sessionFile ?? result?.sessionFile,
506
517
  model: selectedStep.model,
507
518
  thinking: selectedStep.thinking,
519
+ sandbox: selectedStep.sandbox ?? result?.results?.[requestedIndex]?.sandbox ?? result?.sandbox ?? recoveryDescriptor?.sandbox,
508
520
  launchContractDigest: selectedStep.launchContractDigest ?? result?.results?.[requestedIndex]?.launchContractDigest ?? result?.launchContractDigest ?? recoveryDescriptor?.launchContractDigest,
509
521
  ...(selectedStep.runner ? { runner: selectedStep.runner } : {}),
510
522
  ...(selectedStep.externalJob ? { externalJob: selectedStep.externalJob } : {}),
@@ -537,6 +549,7 @@ export function resolveAsyncResumeTarget(params: AsyncResumeParams, deps: AsyncR
537
549
  sessionFile: selected.step.sessionFile ?? status?.sessionFile ?? result?.sessionFile,
538
550
  model: selected.step.model,
539
551
  thinking: selected.step.thinking,
552
+ sandbox: selected.step.sandbox ?? result?.results?.[selected.index]?.sandbox ?? result?.sandbox ?? recoveryDescriptor?.sandbox,
540
553
  launchContractDigest: selected.step.launchContractDigest ?? result?.results?.[selected.index]?.launchContractDigest ?? result?.launchContractDigest ?? recoveryDescriptor?.launchContractDigest,
541
554
  ...(selected.step.runner ? { runner: selected.step.runner } : {}),
542
555
  ...(selected.step.externalJob ? { externalJob: selected.step.externalJob } : {}),
@@ -584,6 +597,7 @@ export function resolveAsyncResumeTarget(params: AsyncResumeParams, deps: AsyncR
584
597
  ...(resolvedSessionFile ? { sessionFile: resolvedSessionFile } : {}),
585
598
  ...(stepModel ? { model: stepModel } : {}),
586
599
  ...(stepThinking ? { thinking: stepThinking } : {}),
600
+ sandbox: statusSteps[index]?.sandbox ?? resultSteps[index]?.sandbox ?? result?.sandbox ?? recoveryDescriptor?.sandbox,
587
601
  launchContractDigest: statusSteps[index]?.launchContractDigest ?? resultSteps[index]?.launchContractDigest ?? result?.launchContractDigest ?? recoveryDescriptor?.launchContractDigest,
588
602
  ...(statusSteps[index]?.runner ? { runner: statusSteps[index]!.runner } : {}),
589
603
  ...(statusSteps[index]?.externalJob ? { externalJob: statusSteps[index]!.externalJob } : {}),
@@ -608,6 +622,7 @@ export function applySteeringRecoveryAgentConfig(agentConfig: AgentConfig, descr
608
622
  subagentOnlyExtensions: descriptor.subagentOnlyExtensions ? [...descriptor.subagentOnlyExtensions] : undefined,
609
623
  mcpDirectTools: descriptor.mcpDirectTools ? [...descriptor.mcpDirectTools] : undefined,
610
624
  mutationTools: descriptor.mutationTools ? [...descriptor.mutationTools] : undefined,
625
+ sandbox: descriptor.sandbox ?? agentConfig.sandbox,
611
626
  systemPrompt: descriptor.systemPrompt ?? agentConfig.systemPrompt,
612
627
  systemPromptMode: descriptor.systemPromptMode,
613
628
  inheritProjectContext: descriptor.inheritProjectContext,
@@ -25,6 +25,7 @@ import { formatWorkflowPreflightPlanSummary, formatWorkflowPreflightWarningSumma
25
25
  import { workflowGraphStageNodes } from "../shared/workflow-graph.ts";
26
26
  import { formatTimeoutRecoveryLines, projectTimeoutRecovery } from "../shared/mutation-evidence.ts";
27
27
  import { formatWorkflowChecklistText, projectWorkflowChecklist } from "../../workflows/workflow-checklist.ts";
28
+ import { validateSandboxProfileName } from "../../shared/sandbox-profile.ts";
28
29
 
29
30
  interface AsyncRunStepSummary {
30
31
  index: number;
@@ -65,6 +66,7 @@ interface AsyncRunStepSummary {
65
66
  model?: string;
66
67
  contextLimit?: number;
67
68
  thinking?: string;
69
+ sandbox?: string;
68
70
  attemptedModels?: string[];
69
71
  sessionFile?: string;
70
72
  transcriptPath?: string;
@@ -106,6 +108,7 @@ export interface AsyncRunSummary {
106
108
  steering?: SteeringStatus;
107
109
  mode: SubagentRunMode;
108
110
  context?: ContextSummary;
111
+ sandbox?: string;
109
112
  cwd?: string;
110
113
  sessionRoot?: string;
111
114
  startedAt: number;
@@ -203,6 +206,14 @@ function isolateCorruptActiveRun(asyncDir: string, runId: string, error: unknown
203
206
  console.error(`[pi-subagents] Skipping corrupt active async run '${runId}' at '${statusPath}': ${getErrorMessage(error)}; ${markerAction}.`);
204
207
  }
205
208
 
209
+ function sandboxProfileValue(value: unknown): string | undefined {
210
+ try {
211
+ return validateSandboxProfileName(value);
212
+ } catch {
213
+ return undefined;
214
+ }
215
+ }
216
+
206
217
  function isNotFoundError(error: unknown): boolean {
207
218
  return typeof error === "object"
208
219
  && error !== null
@@ -327,6 +338,7 @@ function statusToSummary(asyncDir: string, status: AsyncStatus & { cwd?: string
327
338
  const stepActivityState = step.activityState;
328
339
  const stepLastActivityAt = step.lastActivityAt;
329
340
  const timeoutRecovery = projectTimeoutRecovery(step.timeoutRecovery);
341
+ const sandbox = sandboxProfileValue(step.sandbox);
330
342
  return {
331
343
  index,
332
344
  childId: asyncStatusChildIdentity(step, index),
@@ -365,6 +377,7 @@ function statusToSummary(asyncDir: string, status: AsyncStatus & { cwd?: string
365
377
  ...(step.model ? { model: step.model } : {}),
366
378
  ...(step.contextLimit !== undefined ? { contextLimit: step.contextLimit } : {}),
367
379
  ...(step.thinking ? { thinking: step.thinking } : {}),
380
+ ...(sandbox ? { sandbox } : {}),
368
381
  ...(step.thinkingCeiling ? { thinkingCeiling: step.thinkingCeiling } : {}),
369
382
  ...(step.attemptedModels ? { attemptedModels: step.attemptedModels } : {}),
370
383
  ...(step.sessionFile ? { sessionFile: step.sessionFile } : {}),
@@ -395,6 +408,7 @@ function statusToSummary(asyncDir: string, status: AsyncStatus & { cwd?: string
395
408
  };
396
409
  });
397
410
  attachRootChildrenToSteps(status.runId || path.basename(asyncDir), summarizedSteps, nestedChildren);
411
+ const sandbox = sandboxProfileValue(status.sandbox);
398
412
  return {
399
413
  id: status.runId || path.basename(asyncDir),
400
414
  asyncDir,
@@ -412,6 +426,7 @@ function statusToSummary(asyncDir: string, status: AsyncStatus & { cwd?: string
412
426
  steering: status.steering,
413
427
  mode: status.mode,
414
428
  ...(summarizeContextModes(summarizedSteps.map((step) => step.context)) ? { context: summarizeContextModes(summarizedSteps.map((step) => step.context)) } : {}),
429
+ ...(sandbox ? { sandbox } : {}),
415
430
  cwd: status.cwd,
416
431
  ...(status.sessionRoot ? { sessionRoot: status.sessionRoot } : {}),
417
432
  startedAt: status.startedAt,
@@ -129,6 +129,7 @@ import { waitForImportedAsyncRoot } from "./chain-root-attachment.ts";
129
129
  import { normalizeExtensionBindings } from "../shared/extension-bindings.ts";
130
130
  import { appendRunnerStepsToStatus, consumeChainAppendRequests, countPendingChainAppendRequests, statusStepDescription } from "./chain-append.ts";
131
131
  import { asyncStatusChildIdentity } from "../shared/child-identity.ts";
132
+ import { validateSandboxProfileName } from "../../shared/sandbox-profile.ts";
132
133
  import { initialToolBudgetState, toolBudgetState } from "../shared/tool-budget.ts";
133
134
  import { effectiveToolTimeoutMs, formatToolTimeoutMessage, toolTimeoutCallKey } from "../shared/tool-timeout.ts";
134
135
  import { usageBudgetExceededMessage, usageBudgetState } from "../shared/usage-budget.ts";
@@ -142,6 +143,7 @@ import { resolveCursorAgentLaunch } from "../shared/cursor-agent-adapter.ts";
142
143
  import { resolveExternalCliRunnerStatus } from "../shared/external-cli-contract.ts";
143
144
  import { runExternalJob } from "../shared/external-job-runner.ts";
144
145
  import { createOrcaProgressTab, type OrcaProgressTab } from "../shared/orca-progress-tabs.ts";
146
+ import { clearSandboxStartupDiagnostic, readSandboxStartupDiagnostic } from "../shared/sandbox-startup-diagnostics.ts";
145
147
  import type { ResolvedSubagentCapabilityCeiling } from "../shared/capability-ceiling.ts";
146
148
  import {
147
149
  acceptChildWatchdogEvent,
@@ -221,6 +223,7 @@ interface StepResult {
221
223
  /** Human-readable display name for the child session, when derived at launch. */
222
224
  sessionName?: string;
223
225
  context?: "fresh" | "fork";
226
+ sandbox?: string;
224
227
  capabilityCeiling?: ResolvedSubagentCapabilityCeiling;
225
228
  capabilityAudit?: import("../shared/capability-ceiling.ts").SubagentCapabilityAudit;
226
229
  launchResolvedExtensions?: LaunchResolvedChildExtensionsV1;
@@ -271,6 +274,16 @@ interface StepResult {
271
274
  externalJob?: ExternalJobStatus;
272
275
  }
273
276
 
277
+ function commonSandboxProfile(steps: readonly RunnerStatusStep[]): string | undefined {
278
+ const profile = steps[0]?.sandbox;
279
+ if (!profile || !steps.every((step) => step.sandbox === profile)) return undefined;
280
+ try {
281
+ return validateSandboxProfileName(profile);
282
+ } catch {
283
+ return undefined;
284
+ }
285
+ }
286
+
274
287
  function persistStepArtifacts(input: {
275
288
  artifactPaths: ArtifactPaths;
276
289
  artifactConfig?: Partial<ArtifactConfig>;
@@ -782,6 +795,7 @@ async function runSingleStepInner(
782
795
  capabilityCeiling: step.capabilityCeiling ?? ctx.capabilityCeiling,
783
796
  inheritedCapabilityCeiling: ctx.inheritedChildRuntime?.capabilityCeiling,
784
797
  permissionRules: step.permissionRules,
798
+ sandbox: step.sandbox,
785
799
  }));
786
800
  const contractTools = resolvedTaskToolPlan.explicitToolAllowlist ? resolvedTaskToolPlan.effectiveToolAllowlist : undefined;
787
801
  const contractError = validateImplementationToolContract({
@@ -1092,6 +1106,9 @@ async function runSingleStepInner(
1092
1106
  structuredOutput: effectiveStructuredOutput,
1093
1107
  toolBudget: step.toolBudget,
1094
1108
  permissionRules: step.permissionRules,
1109
+ projectTrusted: step.projectTrusted,
1110
+ trustedProjectCwd: step.trustedProjectCwd,
1111
+ sandbox: step.sandbox,
1095
1112
  permissionAuditPath: step.permissionRules && ctx.artifactsDir
1096
1113
  ? path.join(ctx.artifactsDir, "permission-audit", `${ctx.id}-${ctx.flatIndex}.jsonl`)
1097
1114
  : undefined,
@@ -1130,6 +1147,7 @@ async function runSingleStepInner(
1130
1147
  capabilityCeiling: step.capabilityCeiling ?? ctx.capabilityCeiling,
1131
1148
  inheritedCapabilityCeiling: ctx.inheritedChildRuntime?.capabilityCeiling,
1132
1149
  permissionRules: step.permissionRules,
1150
+ sandbox: step.sandbox,
1133
1151
  }));
1134
1152
  launchResolvedExtensions = projectLaunchResolvedChildExtensions(toolPlan);
1135
1153
  actualLaunchContractDigest = launchBindingDigest(omitUndefinedProperties({
@@ -1145,6 +1163,7 @@ async function runSingleStepInner(
1145
1163
  inheritProjectContext: step.inheritProjectContext,
1146
1164
  inheritGlobalContext: step.inheritGlobalContext,
1147
1165
  inheritSkills: step.inheritSkills,
1166
+ sandbox: step.sandbox,
1148
1167
  skills: step.skills,
1149
1168
  tools: toolPlan.effectiveToolAllowlist,
1150
1169
  ...(toolPlan.excludeTools.length > 0 ? { excludeTools: toolPlan.excludeTools } : {}),
@@ -1233,6 +1252,9 @@ async function runSingleStepInner(
1233
1252
  const terminalEmptyAfterUsefulWork = !validatedStructuredOutput
1234
1253
  && hasEmptyTerminalAssistantResponse(run.messages)
1235
1254
  && (run.toolCount > 0 || Boolean(run.finalOutput.trim()));
1255
+ // A startup guard can block the child's first turn, which leaves no message to
1256
+ // inspect; prefer the reason the blocked child published for the launcher.
1257
+ const sandboxStartupDiagnostic = readSandboxStartupDiagnostic(launch.sandboxDiagnosticsPath);
1236
1258
  const emptyOutputError = run.exitCode === 0
1237
1259
  && !run.error
1238
1260
  && !toolAvailabilityError
@@ -1240,8 +1262,10 @@ async function runSingleStepInner(
1240
1262
  && !validatedStructuredOutput
1241
1263
  && (!run.finalOutput.trim() || terminalEmptyAfterUsefulWork)
1242
1264
  && (!hiddenError?.hasError || hasEmptyTerminalAssistantResponse(run.messages))
1243
- ? formatEmptyTerminalAssistantResponseError(run.messages)
1265
+ ? sandboxStartupDiagnostic?.reason ?? formatEmptyTerminalAssistantResponseError(run.messages)
1244
1266
  : undefined;
1267
+ const startupBlocked = sandboxStartupDiagnostic !== undefined && emptyOutputError === sandboxStartupDiagnostic.reason;
1268
+ if (startupBlocked) clearSandboxStartupDiagnostic(launch.sandboxDiagnosticsPath);
1245
1269
  const completionGuardEnabled = isAgentContractV1(step.agentContract) ? step.completionGuard === true : step.completionGuard !== false;
1246
1270
  const completionToolPlan = resolvedTaskToolPlan;
1247
1271
  const completionTools = completionToolPlan ? (completionToolPlan.explicitToolAllowlist ? completionToolPlan.effectiveToolAllowlist : undefined) : step.tools;
@@ -1357,7 +1381,7 @@ async function runSingleStepInner(
1357
1381
  }
1358
1382
  if (completionEvidence.guardTriggered) break modelAttemptsLoop;
1359
1383
 
1360
- const retryableModelFailure = isRetryableModelFailureAttempt({ error, messages: run.messages, toolCount: run.toolCount });
1384
+ const retryableModelFailure = isRetryableModelFailureAttempt({ error, messages: run.messages, toolCount: run.toolCount, ...(startupBlocked ? { startupBlocked: true } : {}) });
1361
1385
  if (retryableModelFailure) recordRetryableModelFailure(candidate ?? run.model ?? step.model, error);
1362
1386
  if (isContextOverflow(error)) {
1363
1387
  contextOverflow = true;
@@ -1494,6 +1518,7 @@ async function runSingleStepInner(
1494
1518
  error: effectiveFinalError,
1495
1519
  acceptance: effectiveAcceptance,
1496
1520
  ...(capabilityAudit ? { capabilityCeiling: capabilityAudit.ceiling, capabilityAudit } : {}),
1521
+ sandbox: step.sandbox,
1497
1522
  launchContractDigest: actualLaunchContractDigest,
1498
1523
  launchResolvedExtensions,
1499
1524
  ...((finalResult as (RunChildSessionResult & { runtimeAcknowledgedExtensions?: RuntimeAcknowledgedChildExtensionsV1 }) | undefined)?.runtimeAcknowledgedExtensions ? { runtimeAcknowledgedExtensions: (finalResult as RunChildSessionResult & { runtimeAcknowledgedExtensions?: RuntimeAcknowledgedChildExtensionsV1 }).runtimeAcknowledgedExtensions } : {}),
@@ -1509,6 +1534,7 @@ async function runSingleStepInner(
1509
1534
  agent: step.agent,
1510
1535
  ...(childSessionName ? { sessionName: childSessionName } : {}),
1511
1536
  context: step.context,
1537
+ ...(step.sandbox ? { sandbox: step.sandbox } : {}),
1512
1538
  ...(step.agentContract ? { agentContract: step.agentContract } : {}),
1513
1539
  launchContractDigest: actualLaunchContractDigest,
1514
1540
  output: outputForSummary,
@@ -1546,6 +1572,9 @@ async function runSingleStepInner(
1546
1572
  launchResolvedExtensions,
1547
1573
  ...((finalResult as (RunChildSessionResult & { runtimeAcknowledgedExtensions?: RuntimeAcknowledgedChildExtensionsV1 }) | undefined)?.runtimeAcknowledgedExtensions ? { runtimeAcknowledgedExtensions: (finalResult as RunChildSessionResult & { runtimeAcknowledgedExtensions?: RuntimeAcknowledgedChildExtensionsV1 }).runtimeAcknowledgedExtensions } : {}),
1548
1574
  });
1575
+ // SAFETY: `result` is the step result assembled above for this same run; agent-contract
1576
+ // projections are attached to that object and re-narrowed to its own type, so the
1577
+ // assertion only re-states the shape the builders already produced here.
1549
1578
  return isAgentContractV1(step.agentContract) ? attachContractProjections(result as unknown as import("../../shared/types.ts").SingleResult) as unknown as typeof result : result;
1550
1579
  }
1551
1580
 
@@ -1902,6 +1931,7 @@ async function runSubagent(
1902
1931
  outputName: task.outputName,
1903
1932
  structured: task.structured,
1904
1933
  ...(task.agentContract ? { agentContract: task.agentContract } : {}),
1934
+ ...(task.sandbox ? { sandbox: task.sandbox } : {}),
1905
1935
  ...(task.launchContractDigest ? { launchContractDigest: task.launchContractDigest } : {}),
1906
1936
  ...(task.launchResolvedExtensions ? { launchResolvedExtensions: task.launchResolvedExtensions } : {}),
1907
1937
  ...(task.capabilityCeiling ? { capabilityCeiling: task.capabilityCeiling } : {}),
@@ -1932,6 +1962,7 @@ async function runSubagent(
1932
1962
  structured: Boolean(step.collect.outputSchema),
1933
1963
  ...(step.parallel.contextLimit !== undefined ? { contextLimit: step.parallel.contextLimit } : {}),
1934
1964
  ...(step.agentContract ? { agentContract: step.agentContract } : {}),
1965
+ ...(step.parallel.sandbox ? { sandbox: step.parallel.sandbox } : {}),
1935
1966
  ...(step.capabilityCeiling ? { capabilityCeiling: step.capabilityCeiling } : {}),
1936
1967
  ...(step.thinkingCeiling ? { thinkingCeiling: step.thinkingCeiling } : {}),
1937
1968
  status: "pending",
@@ -1956,6 +1987,7 @@ async function runSubagent(
1956
1987
  outputName: step.outputName,
1957
1988
  structured: step.structured,
1958
1989
  ...(step.agentContract ? { agentContract: step.agentContract } : {}),
1990
+ ...(step.sandbox ? { sandbox: step.sandbox } : {}),
1959
1991
  ...(step.launchContractDigest ? { launchContractDigest: step.launchContractDigest } : {}),
1960
1992
  ...(step.launchResolvedExtensions ? { launchResolvedExtensions: step.launchResolvedExtensions } : {}),
1961
1993
  ...(step.capabilityCeiling ? { capabilityCeiling: step.capabilityCeiling } : {}),
@@ -1983,6 +2015,7 @@ async function runSubagent(
1983
2015
  step.processTerminal = { version: 1, state: "pending", runId: id, runnerProcessInstanceId: config.runnerProcessInstanceId };
1984
2016
  }
1985
2017
  }
2018
+ const initialSandbox = commonSandboxProfile(initialStatusSteps);
1986
2019
  const initialAgentLabel = initialStatusSteps.length === 1
1987
2020
  ? initialStatusSteps[0]!.agent
1988
2021
  : (config.resultMode ?? (flatSteps.length > 1 ? "chain" : "single")) === "parallel"
@@ -2018,6 +2051,7 @@ async function runSubagent(
2018
2051
  chainStepCount: steps.length,
2019
2052
  parallelGroups,
2020
2053
  workflowGraph: config.workflowGraph,
2054
+ ...(initialSandbox ? { sandbox: initialSandbox } : {}),
2021
2055
  ...(config.launchContractDigest ? { launchContractDigest: config.launchContractDigest } : {}),
2022
2056
  ...(config.launchResolvedExtensions ? { launchResolvedExtensions: config.launchResolvedExtensions } : {}),
2023
2057
  ...(config.capabilityCeiling ? { capabilityCeiling: config.capabilityCeiling } : {}),
@@ -2169,6 +2203,7 @@ async function runSubagent(
2169
2203
  success: state === "complete",
2170
2204
  state,
2171
2205
  summary,
2206
+ ...(statusPayload.sandbox ? { sandbox: statusPayload.sandbox } : {}),
2172
2207
  error: state === "failed" || state === "partial" || state === "stopped" || state === "rejected" ? summary : undefined,
2173
2208
  stopped: state === "stopped" ? true : undefined,
2174
2209
  results: statusPayload.steps.map((step) => omitUndefinedProperties({
@@ -2180,6 +2215,7 @@ async function runSubagent(
2180
2215
  sessionFile: step.sessionFile,
2181
2216
  model: step.model,
2182
2217
  thinking: step.thinking,
2218
+ sandbox: step.sandbox,
2183
2219
  attemptedModels: step.attemptedModels,
2184
2220
  modelAttempts: step.modelAttempts,
2185
2221
  usage: usageFromAttempts(step.modelAttempts),
@@ -3580,6 +3616,7 @@ async function runSubagent(
3580
3616
  setOptionalProperty(requiredStatusStep(statusPayload, fi), "transcriptPath", singleResult.transcriptPath ?? requiredStatusStep(statusPayload, fi).transcriptPath);
3581
3617
  setOptionalProperty(requiredStatusStep(statusPayload, fi), "transcriptError", singleResult.transcriptError);
3582
3618
  setOptionalProperty(requiredStatusStep(statusPayload, fi), "agentContract", singleResult.agentContract);
3619
+ setOptionalProperty(requiredStatusStep(statusPayload, fi), "sandbox", singleResult.sandbox);
3583
3620
  setOptionalProperty(requiredStatusStep(statusPayload, fi), "launchContractDigest", singleResult.launchContractDigest);
3584
3621
  setOptionalProperty(requiredStatusStep(statusPayload, fi), "launchResolvedExtensions", singleResult.launchResolvedExtensions);
3585
3622
  setOptionalProperty(requiredStatusStep(statusPayload, fi), "runtimeAcknowledgedExtensions", singleResult.runtimeAcknowledgedExtensions);
@@ -3616,6 +3653,7 @@ async function runSubagent(
3616
3653
  ...(pr.sessionName ? { sessionName: pr.sessionName } : {}),
3617
3654
  context: pr.context,
3618
3655
  agentContract: pr.agentContract,
3656
+ sandbox: pr.sandbox,
3619
3657
  launchContractDigest: pr.launchContractDigest,
3620
3658
  launchResolvedExtensions: pr.launchResolvedExtensions,
3621
3659
  runtimeAcknowledgedExtensions: pr.runtimeAcknowledgedExtensions,
@@ -3983,6 +4021,7 @@ async function runSubagent(
3983
4021
  setOptionalProperty(requiredStatusStep(statusPayload, fi), "transcriptPath", singleResult.transcriptPath ?? requiredStatusStep(statusPayload, fi).transcriptPath);
3984
4022
  setOptionalProperty(requiredStatusStep(statusPayload, fi), "transcriptError", singleResult.transcriptError);
3985
4023
  setOptionalProperty(requiredStatusStep(statusPayload, fi), "agentContract", singleResult.agentContract);
4024
+ setOptionalProperty(requiredStatusStep(statusPayload, fi), "sandbox", singleResult.sandbox);
3986
4025
  setOptionalProperty(requiredStatusStep(statusPayload, fi), "launchResolvedExtensions", singleResult.launchResolvedExtensions);
3987
4026
  setOptionalProperty(requiredStatusStep(statusPayload, fi), "runtimeAcknowledgedExtensions", singleResult.runtimeAcknowledgedExtensions);
3988
4027
  setOptionalProperty(requiredStatusStep(statusPayload, fi), "effects", singleResult.effects);
@@ -4061,6 +4100,7 @@ async function runSubagent(
4061
4100
  agent: pr.agent,
4062
4101
  context: pr.context,
4063
4102
  agentContract: pr.agentContract,
4103
+ sandbox: pr.sandbox,
4064
4104
  launchContractDigest: pr.launchContractDigest,
4065
4105
  launchResolvedExtensions: pr.launchResolvedExtensions,
4066
4106
  output: pr.output,
@@ -4324,6 +4364,7 @@ async function runSubagent(
4324
4364
  ...(singleResult.sessionName ? { sessionName: singleResult.sessionName } : {}),
4325
4365
  context: singleResult.context,
4326
4366
  agentContract: singleResult.agentContract,
4367
+ sandbox: singleResult.sandbox,
4327
4368
  launchContractDigest: singleResult.launchContractDigest,
4328
4369
  launchResolvedExtensions: singleResult.launchResolvedExtensions,
4329
4370
  runtimeAcknowledgedExtensions: singleResult.runtimeAcknowledgedExtensions,
@@ -4711,6 +4752,7 @@ async function runSubagent(
4711
4752
  transcriptPath: r.transcriptPath,
4712
4753
  transcriptError: r.transcriptError,
4713
4754
  agentContract: r.agentContract,
4755
+ sandbox: r.sandbox,
4714
4756
  launchContractDigest: r.launchContractDigest,
4715
4757
  launchResolvedExtensions: r.launchResolvedExtensions,
4716
4758
  runtimeAcknowledgedExtensions: r.runtimeAcknowledgedExtensions,