Repository navigation
Description
AgentScope-Java is an open-source project. To involve a broader community, we recommend asking your questions in English.
Describe the bug
When a HarnessAgent runs with a Docker sandbox filesystem (DockerFilesystemSpec), the
system prompt injected by WorkspaceContextMiddleware contains two path statements that
are invalid or contradictory from the container's point of view:
The workspace directory is: /app/workspace/office_master— this is the
host-side harness workspace path (set viabuilder.workspace(...)). The path is
never mounted into the container, so it does not exist inside the sandbox.Sandbox root: /workspace (container id: ...)— the container workspace root is
hard-coded as/workspaceinbuildWorkspaceParagraph, ignoring the value actually
configured viaDockerFilesystemSpec.workspaceRoot(...)(stored in
DockerSandboxState.workspaceRoot).
As a result, the model tries to access the advertised host path inside the container,
discovers it does not exist, and burns reasoning turns self-correcting (see thinking trace
below). On more complex tasks this can genuinely mislead the agent.
To Reproduce
Steps to reproduce the behavior:
- Your code
DockerFilesystemSpec filesystemSpec = getDefaultDockerFilesystemSpec();
filesystemSpec.image("python:3.12-slim");
filesystemSpec.memorySizeBytes(512* 1024 * 1024L);
filesystemSpec.cpuCount(1);
filesystemSpec.network("host");
// NOTE: workspaceRoot(...) is NOT set, so the container workspace root
// defaults to /workspace
HarnessAgent agent = HarnessAgent.builder()
.name("office_master")
.model(...)
.workspace(Paths.get("/app/workspace/office_master")) // host-side harness workspace
.filesystem(filesystemSpec)
.build();- How to execute
run the agent with any prompt that makes it inspect its working directory / project files (e.g. "list the files in the workspace"). - See error
the model's reasoning shows the confusion:
<thinking>
The workspace directory doesn't exist at that path. Let me check what directories are available.
The workspace directory is /workspace, not /app/workspace/office_master. Let me check the current working directory and project structure.
</thinking>Expected behavior
Per the javadoc of buildWorkspaceParagraph, the workspace description should branch "by the active filesystem type so the LLM sees a description that matches its real deployment surface". In sandbox mode that means:
- The session-context line
The workspace directory is: %sshould not present the host-side harness workspace path as a directory usable inside the container (it should be omitted or reworded for sandbox mode). - The
Sandbox root:line should report the actual configured container workspace root (e.g. fromDockerSandboxState.getWorkspaceRoot()/DockerSandboxClientOptions.getWorkspaceRoot()), not the hard-coded/workspace. With a customworkspaceRoot, the prompt is currently wrong in the opposite direction.
Error messages
No exception — this is a system-prompt / runtime-environment inconsistency. The observable symptom is the model's thinking trace above: the model discovers the advertised workspace directory does not exist, then falls back to /workspace on its own.
Environment (please complete the following information):
- AgentScope-Java Version: 2.0.3
- Java Version: 21
- OS: Linux (Docker host, sandbox via Docker CLI)
Additional context
- Root cause locations in
agentscope-harness(verified on thev2.0.3tag):WorkspaceContextMiddleware.SESSION_CONTEXT_SECTION_TEMPLATE—The workspace directory is: %sis filled withworkspaceManager.getWorkspace()(host path) regardless of filesystem type (agentscope-harness/src/main/java/io/agentscope/harness/agent/middleware/WorkspaceContextMiddleware.java, line 58).WorkspaceContextMiddleware.buildWorkspaceParagraph— the sandbox branch appends the literalSandbox root: /workspaceinstead of the configured root (agentscope-harness/src/main/java/io/agentscope/harness/agent/middleware/WorkspaceContextMiddleware.java, line 360).
- The host-side workspace itself is by design: it holds
AGENTS.md,MEMORY.md, sessions, skills and is the source of the workspace projection that is copied into the container at sandbox start. The bug is only that its host path is advertised to the model as a usable directory inside the container. - Workaround: setting
filesystemSpec.workspaceRoot("/app/workspace/office_master")aligns the container root with the injected path, but the hard-codedSandbox root: /workspaceline still misleads whenever a custom root is configured, so a source fix is needed. - Suggested fix: in sandbox mode, derive the
Sandbox root:line from the live sandbox state (the per-call sandbox bound bySandboxLifecycleMiddleware, orDockerSandboxState.workspaceRoot), and skip/reword the host workspace path in the session context section for sandbox filesystems.
Activity
oss-maintainer commentedon Sep 18, 2026
Issue Evaluation
Category:
bug| Status: ConfirmedVerified against current
main(be7211d19):WorkspaceContextMiddleware.SESSION_CONTEXT_SECTION_TEMPLATE(line 58) rendersThe workspace directory is: %sfromworkspaceManager.getWorkspace()(line 217) — the host-side path — regardless of the active filesystem type. Inside a Docker sandbox that path does not exist, matching the confusion trace in the report.buildWorkspaceParagraph(line 368) appends the literalSandbox root: /workspace (container id: ...), ignoring the actually configured root (DockerFilesystemSpec.workspaceRoot(...)→DockerSandboxState.getWorkspaceRoot()), so with a customworkspaceRootthe prompt is wrong in the opposite direction.Impact:
agentscope-harnesssandbox mode system prompt only; no data corruption, but it wastes model turns on self-correction and can mislead the agent whenworkspaceRootis customized.Severity: medium.
Next step: an automated fix proposal (spec) will be generated for this issue and posted here as a follow-up comment. The proposed direction matches yours — derive the
Sandbox root:line from the live sandbox state, and omit/reword the host workspace path when a sandbox filesystem is active. Community members: please reply/approveto proceed with PR generation, or/revise//rejectto steer the proposal.Automated evaluation by github-manager-bot
devonking commentedon Sep 18, 2026
HarnessAgent.Builder.build()creates theWorkspacePathNormalizerforFilesystemTool/ArtifactDeliveryToolwith the literalShellPathPolicy.SANDBOX_WORKSPACE_PREFIX(/workspace) instead of the configuredDockerFilesystemSpec.workspaceRoot(...)(agentscope-harness/.../HarnessAgent.java,lines 2708-2710). With a custom workspace root, model-supplied paths starting with
/workspace/are silently re-rooted to the custom root, and absolute paths under the realroot are passed through unnormalized.
ShellPathPolicyreadsdefaultSandboxContext.getClientOptions().getWorkspaceRoot()(HarnessAgent.java lines 2903-2911). The pathNormalizer branch at 2708-2710 was likely
missed in that fix.
oss-maintainer commentedon Sep 19, 2026
Follow-up evaluation — third hard-coded location confirmed, scope widened
@devonking thanks — your addition checks out against
main(d70910700, 2026-09-18). Verified point by point:build()constructs theWorkspacePathNormalizerforFilesystemTool/ArtifactDeliveryToolwith the literal/workspaceHarnessAgent.java:2709-2711→WorkspacePathNormalizer.of(ShellPathPolicy.SANDBOX_WORKSPACE_PREFIX);SANDBOX_WORKSPACE_PREFIX = "/workspace"atShellPathPolicy.java:46of(...)only strips that literal prefix (so a custom root is never stripped)WorkspacePathNormalizer.of(String)at:50-57builds a one-entry prefix list with no configured rootHarnessAgent.java:2904-2909usesdefaultSandboxContext.getClientOptions().getWorkspaceRoot(), falling back to the constantDockerFilesystemSpec.workspaceRoot(...)→DockerSandboxClientOptions.workspaceRoot(...); default/workspaceatDockerSandboxClientOptions.java:39; consumed byDockerSandbox.java:148/205/264Both the
pathNormalizerbranch (:2709) and the skill branch (:2904) match the sameAbstractSandboxFilesystemtype (BaseSandboxFilesystem implements AbstractSandboxFilesystem,BaseSandboxFilesystem.java:55), so the divergence is purely an unwired call site, not a type-shape difference.Two more sites with the same defect that the thread has not listed yet
DockerSandboxClient.java:70-73— re-hard-codes the default (: options.getWorkspaceRoot() != null ? … : "/workspace") instead of delegating toSandboxClientOptions.getWorkspaceRoot(). Harmless today because the options default is also/workspace, but it duplicates the default in a third place, which is how these drift.SandboxClientOptions.java:61-63— the base interface'sgetWorkspaceRoot()returns a literal/workspacerather than being abstract/delegating, so any backend that forgets to override silently reports Docker's root. Kubernetes is exposed through this:KubernetesSandboxClientOptions.java:32andKubernetesSandboxState.java:29carry their ownworkspaceRoot, and fix(sandbox): keep Kubernetes wrap newlines around command #3204 is fixing the Kubernetes wrap path separately.Revised scope of this issue — the report plus this thread now identify three value-level sites (not two), all needing the same treatment:
SESSION_CONTEXT_SECTION_TEMPLATErenders the host workspace path in sandbox mode (WorkspaceContextMiddleware.java:58+:217);buildWorkspaceParagraphprints a literalSandbox root: /workspace(:368);pathNormalizerforFilesystemTool/ArtifactDeliveryTooluses the constant/workspace(HarnessAgent.java:2709-2711), which is the only one of the three that changes behaviour and not just prompt text: with a custom root, model-supplied/workspace/...paths get re-rooted to the real root, and absolute paths under the real root are passed through unnormalized.Items 1-2 are prompt-accuracy; item 3 is a path-resolution correctness issue, so it should be the anchor of the fix, with 1-2 following from the same resolved value.
Updated fix direction (supersedes the direction in my initial evaluation): resolve the effective sandbox workspace root once —
defaultSandboxContext.getClientOptions().getWorkspaceRoot()with theSANDBOX_WORKSPACE_PREFIXfallback already used at:2904-2909— and feed that single value to (a) thepathNormalizerbranch at:2709, (b) theSandbox root:line inbuildWorkspaceParagraph, and (c) the host-path line inSESSION_CONTEXT_SECTION_TEMPLATE(omit or reword it when a sandbox filesystem is active). MakingSandboxClientOptions.getWorkspaceRoot()abstract is the structural cleanup that prevents recurrence; whether to do that here or in a follow-up is a maintainer call, since it touches every backend.Severity unchanged: medium — same blast radius (
agentscope-harnessonly, noagentscope-coreinterface change), but item 3 makes the practical impact larger than "prompt wording" as originally assessed.Status of the proposal: no PR references #3192 as of this scan and no
/approvehas been received yet, so nothing has been generated. @zhangqian7741 (reporter) and @devonking: reply/approveand the spec will be regenerated against the three-site scope above (with a regression test that sets a customworkspaceRootand asserts the normalizer strips the custom root, not/workspace),/revise <text>to steer it, or/rejectto stop.Automated evaluation by github-manager-bot
oss-maintainer commentedon Sep 22, 2026
Status: 72 h feedback window expired — no automated PR will be generated, the proposal window here is closed
The evaluation CTA above (
5738509892, posted 2026-09-19T02:10:26Z) reached its 72-hourfeedback limit at 2026-09-22T02:10:26Z with no own-line
/approve,/revise, or/rejectcommand in the thread, so per our workflow we skip PR generation and no competing PR will
be filed from this proposal window. No action is needed from anyone.
What the thread actually contains after that CTA: nothing. Measured at 02:12Z on
2026-09-22, the window has zero non-bot comments after the CTA and zero reactions on it, so
there was no signal to act on. @devonking and @zhangqian7741 — this is a timing stand-down,
not a verdict on the report.
The finding stands as evaluated, and the three value-level sites are still there on
main:pathNormalizerforFilesystemTool/ArtifactDeliveryToolbuilt from the constant/workspace(HarnessAgent.java:2709-2711vs the configured-root branch at:2904-2909) — the behaviour-changing one: with a customworkspaceRoot, model-supplied/workspace/...paths get re-rooted and absolute paths under the real root pass throughunnormalized.
Sandbox root: /workspaceprinted literally inbuildWorkspaceParagraph(
WorkspaceContextMiddleware.java:368).SESSION_CONTEXT_SECTION_TEMPLATEin sandbox mode(
WorkspaceContextMiddleware.java:58+:217).Two duplication sites the thread surfaced are also unfixed:
DockerSandboxClient.java:70-73re-hard-codes the default instead of delegating toSandboxClientOptions.getWorkspaceRoot(), andSandboxClientOptions.java:61-63returns aliteral instead of being abstract.
No PR references #3192 as of this check (searched across all states), so nothing else is
carrying the fix — the gap is genuinely open, not covered elsewhere.
@devonking if you still want the bot-generated PR, leave a one-line
approvecommand onthis issue and the spec will be regenerated against the three-site scope; a maintainer can
also pick this up directly. Severity as assessed: medium, blast radius limited to
agentscope-harness, noagentscope-coreinterface change.Automated by github-manager-bot