Repository navigation
Description
if (sandboxFilesystemSpec != null) {
capturedSandboxFs = new SandboxBackedFilesystem();
filesystem =
filesystemRoutes.isEmpty()
? capturedSandboxFs
: new RoutedSandboxFilesystem(capturedSandboxFs, filesystemRoutes);
defaultSandboxContext = sandboxFilesystemSpec.toSandboxContext(resolvedWorkspace);
if (isLocalSession(effectiveSession)) {
log.warn(
"[harness] Sandbox mode is using a local AgentStateStore ({})."
+ " Sandbox state will not survive JVM restarts and cannot be"
+ " shared across instances. For production, configure a"
+ " distributed AgentStateStore via .stateStore(...).",
effectiveSession.getClass().getSimpleName());
}
SessionSandboxStateStore stateStore =
new SessionSandboxStateStore(effectiveSession, resolvedAgentId);
SandboxExecutionGuard executionGuard =
sandboxFilesystemSpec.getExecutionGuard() != null
? sandboxFilesystemSpec.getExecutionGuard()
: SandboxExecutionGuard.noop();
SandboxManager sandboxManager =
new SandboxManager(
defaultSandboxContext.getClient(),
stateStore,
resolvedAgentId,
executionGuard);
sandboxLifecycleMw =
new SandboxLifecycleMiddleware(sandboxManager, capturedSandboxFs);
} else if (!filesystemRoutes.isEmpty()) {
filesystem = new CompositeFilesystem(filesystem, filesystemRoutes);
}
因为subAgent的workspace:mode是shared,并且mainAgent设置了filesystemRoutes,导致进入了filesystem = new CompositeFilesystem(filesystem, filesystemRoutes);
io.agentscope.harness.agent.skill.runtime.ShellPathPolicy shellPolicy;
boolean shellToolAvailable =
!disableShellTool
&& ToolFilter.isAllowed(ShellExecuteTool.NAME, resolvedToolsConfig);
if (!shellToolAvailable) {
shellPolicy =
io.agentscope.harness.agent.skill.runtime.ShellPathPolicy.noShell();
} else if (filesystem instanceof LocalFilesystemWithShell) {
shellPolicy =
io.agentscope.harness.agent.skill.runtime.ShellPathPolicy
.localWithShell(resolvedWorkspace);
} else if (filesystem instanceof OverlayFilesystem ov
&& ov.getUpper() instanceof LocalFilesystemWithShell) {
shellPolicy =
io.agentscope.harness.agent.skill.runtime.ShellPathPolicy
.localWithShell(resolvedWorkspace);
} else if (filesystem instanceof SandboxBackedFilesystem
|| (filesystem instanceof RoutedSandboxFilesystem routed
&& routed.primary() instanceof SandboxBackedFilesystem)) {
String wsPrefix =
defaultSandboxContext != null
&& defaultSandboxContext.getClientOptions() != null
? defaultSandboxContext.getClientOptions().getWorkspaceRoot()
: io.agentscope.harness.agent.skill.runtime.ShellPathPolicy
.SANDBOX_WORKSPACE_PREFIX;
shellPolicy =
io.agentscope.harness.agent.skill.runtime.ShellPathPolicy.sandbox(
wsPrefix);
} else {
shellPolicy =
io.agentscope.harness.agent.skill.runtime.ShellPathPolicy.noShell();
}在这里因为是CompositeFilesystem,无法注册execute工具,建议修改为
filesystem instanceof SandboxBackedFilesystem
|| (filesystem instanceof RoutedSandboxFilesystem routed
&& routed.primary() instanceof SandboxBackedFilesystem) || (filesystem instanceof CompositeFilesystem composite && composite.getDefaultBackend() instanceof SandboxBackedFilesystem)
这样修改就能是subAgent获得shell能力
Activity
ningmao-hlyz commentedon Nov 20, 2026
I reproduced the mechanism while auditing the filesystem wrappers, and the scope is a bit wider than the subagent case: any
filesystemRoute(...)makes the builder wrap the primary in aCompositeFilesystem, and that class is a routing layer — it implements neitherexecute/idnor theAbstractSandboxFilesystemmarker. So:shell_executeis never registered (the registration probe tests the marker on the wrapper), which is exactly the "no shell capability" you saw in the subagent;NO_SHELL, so every skill also loses its<files-root>and code-execution block;LocalFilesystemWithShell.Fix ready on
fix/composite-shell-policy: a sandbox-backed primary is now wrapped inRoutedSandboxFilesystem(which is whatfilesystemRoute's own javadoc already promises), and the two capability probes resolve through the routing wrappers via a newFilesystemUtils.primaryBackend. Six new tests, including a builder-level regression that fails onmaintoday. Opening the PR now.fix(harness): keep the shell when filesystem routes are applied
fix(harness): keep the shell when filesystem routes are applied
fix(harness): keep the shell when filesystem routes are applied (agen…