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

[CI] 2.0.x: after the core and harness fixes, the Windows job fails in agentscope-extensions-sandbox-e2b; one test in service-dataplane is flaky

Open aiyili opened this issue 5 days ago • 2 comments

Describe the bug

This is the third layer of the same problem as #4453 and #4455. With #4454 and #4456 applied, the Windows job of a 2.0.x PR gets through agentscope-core, agentscope-harness and the next modules, and then fails in agentscope-extensions-sandbox-e2b. Seen in the CI of #4456.

To find what is behind it without waiting for one CI run per layer, I ran the whole reactor on a Windows machine with -Dmaven.test.failure.ignore=true: 96 modules, 11301 tests, 7 errors. Four of them need the symlink privilege that this machine does not have and do not occur on the runner. The other three are below.

Error messages

1. agentscope-extensions-sandbox-e2b, 2 errors

E2bSandboxOptionsAndStateTest.resumedLegacyStateMaterializesEntriesUnderSavedExecutionRoot:197 » SandboxConfiguration E2B workspaceRoot must be an absolute in-sandbox path but was: C:\Users\...\junit-...\saved-execution
E2bSandboxRecoveryTest.nativeRestoreAfterConnectFailurePreservesEditsAndUnchangedProjection:433 » SandboxConfiguration E2B workspaceRoot must be an absolute in-sandbox path but was: C:\Users\...\junit-...\workspace

Both tests use a directory under @TempDir as the in-sandbox workspace root, so that they can read the files on disk. E2bSandboxClient.normalizeWorkspaceRoot requires a root that starts with /, which is right for a sandbox that is always Linux. A host directory only looks like an in-sandbox path on a POSIX host, so these two tests cannot pass on Windows.

main has the same tests, and its Windows job is green: main's E2bSandbox.alignWorkspaceRoot does not validate the saved root, while the 2.0.x backport does, which is why they pass there.

Apart from these two, the symlink tests and the test in the next section, every module of the reactor passed on the Windows machine.

2. agentscope-service/service-dataplane, 1 error, not Windows-specific

ToolConfirmationCoordinatorTest.replacementTurnLeaseCannotReleaseOldTicketAndMayReuseToolUseId:452 » CannotStubVoidMethodWithReturnValue 'appendSessionEvent' is a *void method* and it *cannot* be stubbed with a *return value*!

Line 452 is when(controlPlaneClient.managedExecutionScope("session-a")), executed after the test has started requests. The threads those requests start call controlPlaneClient.appendSessionEvent(...) in the background. When one of them does so between the call inside when(...) and the stubbing, Mockito takes that void call as the one to stub. Repeating the test 300 times in one JVM on unmodified 2.0.x gave the error twice. It passed in the Ubuntu job of #4456, so it depends on timing.

To Reproduce

  1. On Windows: mvn -pl agentscope-extensions/agentscope-extensions-sandbox/agentscope-extensions-sandbox-e2b test
  2. For the second: repeat ToolConfirmationCoordinatorTest#replacementTurnLeaseCannotReleaseOldTicketAndMayReuseToolUseId; it fails in well under one run in a hundred.

Expected behavior

The Windows job of a 2.0.x PR runs to the end of the reactor, and the tests that pass do not fail at random.

Suggested fix

  • For 1, enable the two tests on Linux and macOS only, with the reason next to them.
  • For 2, stub with doReturn(...).when(controlPlaneClient).managedExecutionScope("session-a"), which does not depend on the last invocation on the mock.

I'll open a PR against 2.0.x, stacked on #4456.

Environment

  • AgentScope-Java Version: 2.0.x at 50886798 with #4454 and #4456 (57cdbc0f)
  • Java Version: 17
  • OS: Windows (GitHub windows-latest for the first, Windows 10 locally for both)

aiyili avatar Nov 27 '26 08:11 aiyili

Taking this one. I'll open a PR against 2.0.x, stacked on #4456: the two e2b tests limited to POSIX hosts, and the stubbing in ToolConfirmationCoordinatorTest changed to doReturn(...).when(...). I'll confirm the second with repetitions before and after.

aiyili avatar Nov 27 '26 08:11 aiyili

Opened #4461 against 2.0.x, stacked on #4456.

One correction to the suggested fix above: changing the stubbing to doReturn(...).when(...) is not enough. It removed the CannotStubVoidMethodWithReturnValue failure, but repeating the test then failed in another way, 7 times in 1000: expected: "attempt-b" but was: "attempt-a". The ticket at that point is a new one, with the second request's lease and input, built from the old scope. The stubbing was still lost; the window only moved, to between registering the answer and the call that is meant to be stubbed. The stubbing is made once now, before any request, and switched through an AtomicReference. With that, 2000 repetitions gave no error.

The two e2b tests are enabled on Linux and macOS only. They still run and pass in a Linux container; on Windows the e2b module has no error left.

aiyili avatar Nov 27 '26 09:11 aiyili