Skip to content

fix(harness): make path handling host-independent on Windows on 2.0.x (#4455) - #4456

Closed
aiyili wants to merge 3 commits into
agentscope-ai:2.0.xfrom
aiyili:fix/ci-windows-harness-paths-20x
Closed

aiyili wants to merge 3 commits into
agentscope-ai:2.0.xfrom
aiyili:fix/ci-windows-harness-paths-20x

Conversation

@aiyili

@aiyili aiyili commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4455

Stacked on #4454: the first commit is that PR's, so that the CI of this one gets past agentscope-core and shows the harness result. The other two commits are this PR's.

Problem

With #4454 applied, the Windows job of a 2.0.x PR fails in agentscope-harness on 18 tests, and every module after the harness is skipped. The same tests fail on a Windows machine on unmodified 2.0.x. On Linux the module passes. Three causes, all about paths on Windows.

Fix

Sandbox workspace root

12 errors in HarnessAgentTest and SandboxFilesystemIsolationScopeExampleTest:

Sandbox workspace root must be an absolute path but was: C:\Users\...\agentscope-inmemory-sandbox-...\...

SandboxWorkspaceRoot.normalize accepted only roots that start with /. The in-memory sandbox used by these tests reports a host directory as its root, which is a drive path on Windows, so every call that builds the system prompt or a path normalizer failed.

A drive path is accepted now, on every host. Relative, drive-relative (C:ws) and UNC roots are still rejected, and roots are still normalized. #3646 brought the class to main without that check (6ff7590a); the 2.0.x backport (30d13bd2) added it. This keeps the backport's behaviour and only corrects what it counts as absolute.

Project-aware overlay

5 failures in MemoryConsolidatorCommitGateTest:

checkedUploadCannotBypassRejectingProjectWriterOnCompositeExactRoute:763  expected: <false> but was: <true>

ProjectAwareOverlay.isWorkspacePath told an absolute path from a relative one with Path.isAbsolute(). On a Windows host, a path with a leading separator is not absolute for that method. /MEMORY.md, which is the spelling the CompositeFilesystem hands its backends, was therefore matched against the workspace prefixes as if it were relative, classified as a workspace file and written to the workspace layer. The project writer, which these tests make reject the write, was bypassed.

A leading separator now counts as absolute wherever the code runs. That is what the class already did on Linux and what isWorkspacePath_absoluteOutsideWorkspace_returnsFalse states as the intent; that test only covers the spelling with a drive.

Path.isAbsolute() is no longer consulted for this decision. On either host it could only be true here for a drive path outside the workspace root, and such a path matches no workspace prefix either way, so the result is the same without it. The check is now the same on every host, and both of its outcomes run on Linux, where coverage is collected.

main has the same code and not these tests, so on Windows the bypass exists there too. I have not touched main.

One test

1 error in MemoryFlushSandboxIndependenceTest: Path.of("").toAbsolutePath().relativize(workspace) cannot cross drives, as in #4453. The relative workspace is now taken under the module's target/, which is on the drive a relative path is resolved against.

A race found while verifying

With the three fixes in place, a full run on Windows failed once in LocalFilesystemPersonalAssistantExampleTest.localFilesystem_filesPersistAcrossCalls, which asserts that MEMORY.md is unchanged after the second call. With memory hooks on, the flush that runs in the background after a call can consolidate into MEMORY.md. The test is about files persisting, so it now disables memory hooks. The numbers are in the last commit's message.

Tests

Two cases were added, each of which holds on any host:

  • SandboxWorkspaceRootTest.driveRootsAreAcceptedOnEveryHost
  • ProjectAwareOverlayTest.isWorkspacePath_rootRelativeOutsideWorkspace_returnsFalseOnEveryHost

On Windows, the 18 tests pass with the change. Each piece of the fix was then broken on its own, also on Windows:

Broken piece Caught by
workspace root: only / roots are absolute driveRootsAreAcceptedOnEveryHost, and the 5 SandboxFilesystemIsolationScopeExampleTest cases
workspace root: every non-blank root is absolute driveRootsAreAcceptedOnEveryHost, activeRootIsNormalizedAndInvalidRootsFailFast
overlay: a leading separator is not absolute (the old behaviour) isWorkspacePath_rootRelativeOutsideWorkspace_returnsFalseOnEveryHost, and the 5 MemoryConsolidatorCommitGateTest cases
overlay: any path containing a separator is absolute (too broad) isWorkspacePath_classifiesCorrectly and 3 write-routing cases
overlay: no check for absolute paths at all not caught

The first four are caught. The third is invisible on Linux, where the old and the new code agree.

The fifth is not caught, and cannot be: matchesWorkspacePrefix does not strip a leading separator, so /MEMORY.md matches no prefix and the result is the same with or without the check. The bug was the old loop that stripped the separators before matching, which only ran on Windows. The check is kept because it states the rule and does not depend on how the prefix match is written.

Verification

The full agentscope-harness suite was run before and after the change on Windows and in a Linux container. "Before" is unmodified 2.0.x.

Environment Before After Failing after
Windows 1619 run, 5 F + 12 E 1621 run, 0 F + 0 E none
Linux container (maven:3.9-eclipse-temurin-17) 1619 run, 3 F + 1 E 1621 run, 3 F + 1 E 3 × BaseSandboxFilesystemTest.edit_* (python3: not found in the image), MarketplaceStagerOrphanGcTest.unreadableEntryDoesNotFailStage

The only difference on Linux is the 2 added tests. The first full run on Windows, without the last commit, had the one failure described under "A race found while verifying"; the second, with it, has none.

Effect on CI

The CI run of this PR shows the change: on Windows, agentscope-core and agentscope-harness both pass now. For the harness that is 1621 tests with 0 failures, the first time the module passes on the Windows runner since the two backports of 2026-11-13. The job then goes on through the next modules and fails in agentscope-extensions-sandbox-e2b, on two tests that pass a host directory as an in-sandbox workspace root, which the production code rightly rejects on Windows. That is a separate problem and not part of this PR; the harness module is what this PR is about. It is fixed in #4461, which is stacked on this PR, and whose CI is green on both systems with this PR's commits on the branch.

…scope-ai#4453)

`SkillBoxTest$UploadContainment.preservesLegacyNamesWithRelativeNonNormalizedWorkDirectory` started with `Path.of("").toAbsolutePath().relativize(tempDir)`. A relative path cannot cross drives, and on the Windows runner the checkout is on `D:` while `java.io.tmpdir` is on `C:`, so that line threw `'other' has different root` before `SkillBox` was called. Since the backport of agentscope-ai#3787 (`508d5e27`) it has failed the Windows job of every `2.0.x` PR and got the Ubuntu job cancelled.

The directory the test relativizes is now created under the module's `target/`, which is on the drive a relative path is resolved against, and is removed afterwards. What the test asserts and the code it exercises are unchanged: with `SkillUtil.resolveContainedPath` no longer normalizing its base directory, this is the one test in the class that fails.
@aiyili

aiyili commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

About the CI of this PR: on Windows, agentscope-core and agentscope-harness both pass now. For the harness that is 1621 tests with 0 failures, the first time the module passes on the Windows runner since the backports of 2026-11-13.

The job still shows red because it gets further and fails in agentscope-extensions-sandbox-e2b, on two tests that pass a host directory as an in-sandbox workspace root. That is a separate problem from the harness module and not part of this PR.

…agentscope-ai#4455)

Three Windows path problems kept the harness module red on the Windows job of every `2.0.x` PR, 18 tests in all, so that module and everything after it was never tested by CI on this branch.

`SandboxWorkspaceRoot.normalize` accepted only roots that start with `/`. The in-memory sandbox used by the tests reports a host directory as its root, which is a drive path on Windows. A drive path is accepted now, on every host; relative, drive-relative and UNC roots are still rejected.

`ProjectAwareOverlay.isWorkspacePath` relied on `Path.isAbsolute()` to tell an absolute path from a relative one. On a Windows host a path with a leading separator is not absolute for it, so `/MEMORY.md`, the spelling the `CompositeFilesystem` hands its backends, was matched against the workspace prefixes as if it were relative. It was then written to the workspace layer, which bypasses the project writer and its rejection. A leading separator now counts as absolute wherever the code runs.

`MemoryFlushSandboxIndependenceTest` relativized the temp directory from the working directory, which cannot cross drives, as in agentscope-ai#4453.

Tests: `SandboxWorkspaceRootTest` and `ProjectAwareOverlayTest` each gain a case that holds on every host.
… test

`LocalFilesystemPersonalAssistantExampleTest.localFilesystem_filesPersistAcrossCalls` asserts that MEMORY.md is unchanged after the second call. With memory hooks on, the flush that runs in the background after a call can consolidate into MEMORY.md, so that assertion depended on whether the flush had finished. Repeating the scenario 50 times on unmodified `2.0.x` changed MEMORY.md once, to the stub model's reply.

The test is about files persisting across calls, not about memory, so it now disables memory hooks. With them disabled, 50 repetitions did not change MEMORY.md.
@aiyili
aiyili force-pushed the fix/ci-windows-harness-paths-20x branch from 57cdbc0 to 43f29af Compare November 27, 2026 10:01
@jujn jujn closed this Nov 27, 2026
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.

2 participants