Skip to content

[Bug]:2.0.5中创建subAgent因为filesystem是CompositeFilesystem,导致无法获取shell能力 #4292

Closed

Description

@BEN5890

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

  1. added
    bug
    on Nov 20, 2026
  2. ningmao-hlyz commented on Nov 20, 2026

    @ningmao-hlyz
    Contributor

    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 a CompositeFilesystem, and that class is a routing layer — it implements neither execute/id nor the AbstractSandboxFilesystem marker. So:

    • shell_execute is never registered (the registration probe tests the marker on the wrapper), which is exactly the "no shell capability" you saw in the subagent;
    • the skill shell policy resolves to NO_SHELL, so every skill also loses its <files-root> and code-execution block;
    • the same happens in local mode when a route is declared over a LocalFilesystemWithShell.

    Fix ready on fix/composite-shell-policy: a sandbox-backed primary is now wrapped in RoutedSandboxFilesystem (which is what filesystemRoute's own javadoc already promises), and the two capability probes resolve through the routing wrappers via a new FilesystemUtils.primaryBackend. Six new tests, including a builder-level regression that fails on main today. Opening the PR now.

  3. added a commit that references this issue on Nov 23, 2026
    d83fe60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions