Skip to content

fix(harness): keep the shell when filesystem routes are applied - #4304

Merged
jujn merged 1 commit into
agentscope-ai:mainfrom
ningmao-hlyz:fix/composite-shell-policy
Nov 23, 2026
Merged

jujn merged 1 commit into
agentscope-ai:mainfrom
ningmao-hlyz:fix/composite-shell-policy

Conversation

@ningmao-hlyz

@ningmao-hlyz ningmao-hlyz commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.1.0-SNAPSHOT

Description

Fixes #4292.

Any agent that declares a filesystem route loses shell_execute. The builder wrapped the primary filesystem in a CompositeFilesystem, which routes paths but implements none of the capabilities it wraps — no execute/id, no AbstractSandboxFilesystem marker, no sandbox workspace prefix — so every probe that reads the filesystem concluded "this workspace has no shell":

  • shell_execute was never registered (HarnessAgent probed the marker on the wrapper);
  • the skill shell policy resolved to NO_SHELL, so every skill lost its <files-root> and code-execution block;
  • in local mode the same loss hit LocalFilesystemWithShell + a route.

A subagent with workspace.mode=shared over a sandbox-backed parent is the reported case: it inherits the parent filesystem, gets routes applied, and ends up with no shell.

Composition. filesystemRoute's javadoc already promises "when the primary filesystem is sandbox-backed, the route is applied via RoutedSandboxFilesystem so shell_execute still targets the sandbox" — that held for the sandbox-spec branch but not for an injected primary. withFilesystemRoutes now applies the same rule to any primary that executes commands in a sandbox, so a custom BaseSandboxFilesystem (the SharedSandboxFilesystem shape) and an overlay over a sandbox keep execute/id. A host shell stays on a plain composite: LocalFilesystemWithShell implements AbstractSandboxFilesystem too, and routing it would make the probes read host paths as /workspace paths.

Probes. Shell tool registration and the skill shell policy now resolve the filesystem through FilesystemUtils.primaryBackend, which peels CompositeFilesystem and RoutedSandboxFilesystem. The two also agree on the same marker now: registration has always used AbstractSandboxFilesystem, the policy used the narrower SandboxBackedFilesystem, so a routed custom sandbox filesystem got a shell tool while every skill was told there was none.

Deliberately not changed:

  • primaryBackend does not peel OverlayFilesystem: an overlay is a single filesystem that already exposes shell execution through its upper layer, and the existing probes rely on that distinction.
  • The path normalizer for filesystem tools is untouched. It has the same wrapper-blind shape, but changing its classification would move forSandbox prefix handling for callers that currently take the local branch, which is a separate decision.
  • Uploads are unaffected.

How to test

  • HarnessAgentFilesystemRoutesShellTest (new, 8 cases): routed sandbox primary resolves to RoutedSandboxFilesystem and still reports the sandbox marker; routed non-sandbox primary stays composite; an overlay over LocalFilesystemWithShell stays composite so its skills keep host paths; the shell tool is registered for a routed local-with-shell workspace and for a routed sandbox-backed primary; the skill policy returns SANDBOX / LOCAL_WITH_SHELL / NO_SHELL through both wrappers and matches the unwrapped decision.
  • FilesystemUtilsTest: primaryBackend passthrough, composite/routed/nested unwrap, overlay left alone.

Red/green, with the composition and probe changes reverted:

Tests run: 8, Failures: 4
  withFilesystemRoutes_keepsTheSandboxShell              expected RoutedSandboxFilesystem, was CompositeFilesystem
  filesystemRoutes_keepTheShellToolRegistered            a routed workspace ... must keep its shell tool ==> expected true, was false
  filesystemRoutes_keepTheShellToolRegisteredForSandboxPrimary   expected true, was false
  skillShellPolicy_looksThroughRoutingWrappers           expected SANDBOX, was NO_SHELL

Full module on this head: mvn -pl agentscope-harness test → 1904 tests, 0 failures, 47 skipped (Windows host; the skipped ones are docker/shell integration).

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.) — filesystemRoute's javadoc already described the fixed behaviour; no user-facing doc mentions the loss
  • Code is ready for review

@ningmao-hlyz
ningmao-hlyz force-pushed the fix/composite-shell-policy branch from 6bad5f2 to 6c10937 Compare November 20, 2026 15:54
A filesystem route wrapped the primary filesystem in a CompositeFilesystem,
which routes paths but implements none of the capabilities it wraps: no
execute, no AbstractSandboxFilesystem marker, no sandbox workspace prefix. Any
routed workspace therefore lost shell_execute, and with it the skill runtime's
code-execution block and <files-root>; a subagent sharing its parent's
sandbox-backed workspace was the visible case (agentscope-ai#4292).

Composition now matches what filesystemRoute documents: a primary that executes
commands in a sandbox keeps execute/id through RoutedSandboxFilesystem, which
routes the same way and forwards them to the primary. A local shell stays on a
plain composite, since routing an overlay over LocalFilesystemWithShell would
make the workspace probes read host paths as sandbox paths.

The probes that read the filesystem now resolve it through
FilesystemUtils.primaryBackend and agree on one marker, so a routed workspace
over any shell-capable primary keeps its shell, and a custom
BaseSandboxFilesystem no longer gets shell_execute while its skills are told
there is no shell.

primaryBackend peels CompositeFilesystem and RoutedSandboxFilesystem only: an
overlay is a single filesystem that already exposes shell execution through its
upper layer, and callers rely on that distinction.
@ningmao-hlyz
ningmao-hlyz force-pushed the fix/composite-shell-policy branch from 6c10937 to 5305b27 Compare November 20, 2026 16:49
@jujn
jujn merged commit d83fe60 into agentscope-ai:main Nov 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants