Skip to content

fix(harness): honor active sandbox workspace roots - #3646

Merged
juruoO-o merged 8 commits into
agentscope-ai:mainfrom
logicwu0:fix/3645-sandbox-workspace-root
Nov 12, 2026
Merged

juruoO-o merged 8 commits into
agentscope-ai:mainfrom
logicwu0:fix/3645-sandbox-workspace-root

Conversation

@logicwu0

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.1.0-SNAPSHOT, based on main 40a4a57ad79e82f8505572d3b195d0264ec7efcb.

Description

Fixes #3645.

The sandbox workspace paragraph and file-tool path normalizer used /workspace even when the active sandbox used a different directory. E2B also kept its execution root and workspace manifest root independent, including the default /home/user versus /workspace mismatch.

Changes

  • Resolve the sandbox root from the acquisition bound to the current RuntimeContext, not a shared filesystem field. Use this for the workspace paragraph and registered filesystem/artifact path normalization. Restored state takes precedence over build-time defaults; released acquisitions are rejected.
  • Preserve nonmatching and relative paths for the existing filesystem policy. Match prefix boundaries and handle trailing slashes and the filesystem root.
  • Align E2B's effective workspace specification and execution options. Keep /home/user as the default; either root setter can configure the directory. Copy the caller's specification so entries/environment survive without mutating it.
  • When constructing an E2B sandbox from older state, retain its saved execution directory and align only the manifest. No files are moved, and no lifecycle or snapshot algorithm is changed.
  • Add regression tests and matching English/Chinese sandbox documentation. Docker's default remains /workspace.

Compatibility decision for review

As asked in the issue comment, this implementation rejects explicitly conflicting workspaceRoot(...) and workspaceSpec(...).root values when building the context, independent of setter order (trailing slashes are ignored). This policy is proposed for review, not yet maintainer-approved. Existing persisted E2B state is handled differently: its saved execution root stays authoritative so resuming does not relocate the workspace. Please confirm whether fail-fast is preferred for new conflicting configurations.

Validation

JDK 21, Java 17 compilation target, Maven 3.10.0. No real model or E2B service was contacted.

Before the fix, three new offline assertions failed: the prompt advertised /workspace for an active /home/user sandbox, and default/custom E2B roots did not reach the workspace specification. The two existing sandbox-prompt tests passed.

Final command from the repository root:

mvn -o -B -T1 -ntp \
  -pl agentscope-extensions/agentscope-extensions-sandbox/agentscope-extensions-sandbox-e2b -am \
  '-Dtest=SandboxWorkspaceRootTest,WorkspaceContextMiddleware*Test,HarnessAgentTest,*Sandbox*Test,FilesystemToolTest' \
  -Dsurefire.failIfNoSpecifiedTests=false spotless:apply test
  • Harness: 224 tests, 0 failures/errors, 17 skipped.
  • E2B: 57 tests, 0 failures/errors, 1 skipped.
  • Total: 263 passed, 18 skipped. The selection includes existing sandbox recovery, file-transfer and Harness tests; this is not a full-repository result.
  • Regression coverage includes default/custom roots, setter order/conflicts, invalid roots, legacy-state resume, caller-owned manifest preservation, per-call root isolation, the registered read_file tool, prefix boundaries and released acquisitions.
  • Spotless checks and git diff --check passed.
  • In docs/: npm test passed 13 tests; npm run check passed for 430 pages/584 redirects; npm run broken-links reported no broken links.

Remaining validation gaps: full-repository offline clean verify could not start because maven-clean-plugin:3.5.0 was not cached. npm run validate passed the local checker but the Mintlify build did not complete (initial network-check exception, then a network-enabled retry remained at validating build and was interrupted). No full-suite or remote-sandbox success is claimed.

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test) — targeted results above; full suite not completed
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated
  • Code is ready for review, including the explicit configuration-conflict policy question above

@Peng-io

Peng-io commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Thanks for picking this up — the scope looks right.

On the compatibility question: fail-fast for explicit conflicts is what I'd prefer, with one distinction that I think is the crux of the original report:

  • workspaceRoot("/home/user") set on its own, with WorkspaceSpec.root left at its /workspace default, is not a conflict. It is exactly the configuration that produced this issue. It should be treated as "only the execution root was configured" and copied into the effective WorkspaceSpec.root, not rejected — otherwise every existing E2B caller that only sets workspaceRoot(...) starts failing at build time after upgrading.
  • Rejecting should apply only when the caller sets both explicitly and the values differ.

If the implementation already tracks that distinction, could you add an explicit regression test for the "only workspaceRoot(...) set, manifest left at its default" case? That is the scenario from the report and by far the most common configuration.

For persisted state, keeping the saved execution directory authoritative and only aligning the manifest is the right call. Relocating an existing workspace would be far more disruptive than the mismatch itself.

Thanks.

@mintlify

mintlify Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit c4f96fb.

Approve preview

@logicwu0

Copy link
Copy Markdown
Contributor Author

Thanks for clarifying the compatibility requirement. I added the exact regression case with only workspaceRoot("/home/user") configured and the manifest left at its default.

The additional tests exposed a related gap: supplying a WorkspaceSpec for entries/environment without calling setRoot(...) was incorrectly treated as an explicit root configuration. This is now fixed by tracking whether the root setter was called, preserving that distinction through copy(), and excluding the marker from JSON.

The follow-up covers:

  • Execution root only: the effective manifest inherits /home/user.
  • A supplied manifest with an untouched default root: no conflict, in either builder-call order; entries/environment are retained and the caller's manifest is unchanged.
  • Both roots explicitly configured differently: fail-fast remains, including an explicit setRoot("/workspace") in either order.
  • Persisted state: the existing saved-directory-authoritative behavior and regression test are unchanged; no workspace relocation.

Added a JSON/copy regression test as well: the serialized shape is unchanged, a root present in JSON is explicit, and an absent root retains default semantics.

Validation: the targeted Harness/E2B suite reports 286 tests, 268 passed and 18 skipped, with no failures/errors; formatting and documentation tests, link checks, and build validation passed. Full offline Maven clean verify could not start because maven-clean-plugin:3.5.0 is not cached locally, so I am not claiming a full-repository build pass.

@jujn jujn added the P1 紧急不重要 label Nov 3, 2026

@juruoO-o juruoO-o left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed call-scoped workspace root resolution, E2B root alignment and restored-state handling. Approving the explicit conflicting-root fail-fast policy described in the PR.

No blocking findings in the reviewed diff. This was a static review of source and tests; local Java/Maven tests were not run.

@CLAassistant

CLAassistant commented Nov 12, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@juruoO-o juruoO-o left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved current-main conflicts using the PR root configuration and call-scoped resolver, retaining unrelated current backend/host prompt behavior and existing tests. Also fixed restored-state root alignment to run before the superclass caches its workspace materializer root, and added a public start-path regression verifying entry placement under the saved execution root. Updated the existing core JSON assertion to the strict contract from the separately approved #3697 merge.

Conflict resolutions pass git diff --check. Local Java/Maven is unavailable; the updated head is being validated by the repository CI.

Resolve conflicts using the PR root configuration and call-scoped resolver while retaining current host/backend prompt behavior and existing regressions. Align restored E2B roots before superclass materializer initialization and cover entry placement under the saved execution root.
@juruoO-o
juruoO-o force-pushed the fix/3645-sandbox-workspace-root branch 2 times, most recently from a937655 to 463b902 Compare November 12, 2026 14:35

@juruoO-o juruoO-o left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-approving the latest conflict-resolution head after correcting the author/committer identity to the authenticated GitHub account. The source tree is identical to the previously reviewed resolution. CI is validating this head; local Java/Maven tests were not run.

@juruoO-o juruoO-o left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the latest integration follow-ups: strict JSON decoding assertions, heartbeat test synchronization after the recovered request body is available, and deterministic exact comparison of skill upload paths. Existing content/containment and generation assertions remain intact. Resume now consistently retains the saved execution root, with the conflicting legacy root-policy tests updated to that contract; constructor-time root alignment and the entry-placement regression are retained.

Diff whitespace checks pass. Full repository CI is running on this head; local Java/Maven was unavailable.

@juruoO-o

Copy link
Copy Markdown
Collaborator

Integration validation update:

Recording the remaining Linux CI exception explicitly rather than claiming an all-green run. The requested workspace-root conflict resolutions and follow-up fixes are complete; proceeding with the maintainer-authorized normal squash merge, subject to GitHub branch protections.

@juruoO-o
juruoO-o merged commit 6ff7590 into agentscope-ai:main Nov 12, 2026
11 of 15 checks passed
chickenlj pushed a commit that referenced this pull request Nov 13, 2026
Backport the verified fix to the 2.0.x implementation and retain its existing public contracts where the upstream kernel differs.

(cherry picked from commit 6ff7590)
Backport-review-patch: 20ac0cdde54e10c902c5a939f516ef3bd563b0b4
Constraint: No AgentScope Service or SDK migration
Confidence: high
Not-tested: Whole-repository verification pending after lane integration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 紧急不重要

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Sandbox system prompt and path normalizer hardcode "/workspace", ignoring the configured sandbox root

5 participants