agentscope-java icon indicating copy to clipboard operation
agentscope-java copied to clipboard

[Bug]: Sandbox system prompt leaks host OS, host workspace, and host JVM temp paths

Open chcodex opened this issue 3 weeks ago • 0 comments

AgentScope-Java is an open-source project. To involve a broader community, we recommend asking your questions in English.

Describe the bug

When the harness runs against a pure sandbox execution backend (an AbstractSandboxFilesystem that is not wrapped in a OverlayFilesystem), WorkspaceContextMiddleware still renders host facts in the ## Runtime Environment section of the system prompt:

The host operating system is: <host OS>
The host workspace directory is: <host workspace path>
The host JVM temporary directory is: <host java.io.tmpdir>

These facts are not actionable inside the sandbox. They also contradict the ## Workspace paragraph, which used to say that "host paths above do not establish its working directory". As a result the model is often misled into using host paths, host shell syntax, or host temporary directories instead of the configured execution backend.

To Reproduce

  1. Configure a HarnessAgent with a pure sandbox filesystem, e.g. a SandboxBackedFilesystem or a RoutedSandboxFilesystem without an overlay.
  2. Run any call and inspect the rendered system prompt (for example via WorkspaceContextMiddleware#onSystemPrompt / WorkspaceContextMaterials).
  3. Observe the ## Runtime Environment block containing the host operating system, host workspace directory, and host JVM temporary directory.

A focused reproduction also exists in WorkspaceContextMiddlewareSandboxPromptTest: the sandbox prompt assertions previously expected those host lines to be present.

Expected behavior

For a pure sandbox execution surface, ## Runtime Environment should contain only the agent identity and optional environment memory. Host OS, host workspace, and host JVM temporary directory must be omitted. Direct local shell (LocalFilesystemWithShell), local overlay, plain local, and CompositeFilesystem (remote template fallback) deployments should keep the host facts, because they are meaningful there.

The sandbox ## Workspace paragraph should state positively that file and shell paths follow the configured execution backend and that its shell syntax, installed runtimes, and temporary paths should be used, instead of referring to ambiguous "host paths above".

Error messages

No exception is raised; this is a prompt-quality defect. The misleading text is:

The host workspace directory is: /home/user/.agentscope/workspace
The host JVM temporary directory is: /tmp

inside a prompt whose workspace section otherwise describes a sandbox backend.

Environment (please complete the following information):

  • AgentScope-Java Version: 2.1.0-SNAPSHOT (upstream/main at 874c9cb0f)
  • Java Version: 17
  • OS: Linux (also reproducible on macOS and Windows)

Additional context

The root cause is in agentscope-harness/src/main/java/io/agentscope/harness/agent/middleware/WorkspaceContextMiddleware.java: SESSION_CONTEXT_SECTION_TEMPLATE is unconditional and buildSessionContextSection has no filesystem awareness.

Docs that describe the old behavior: docs/v2/en/docs/harness/workspace.md and docs/v2/zh/docs/harness/workspace.md.

chcodex avatar Nov 11 '26 05:11 chcodex