Skip to content

fix(sandbox): rebind RemoteSnapshotClient on state deserialize - #2423

Open
Blue-Berrys wants to merge 2 commits into
agentscope-ai:mainfrom
Blue-Berrys:fix/2303-remote-snapshot-rebind
Open

fix(sandbox): rebind RemoteSnapshotClient on state deserialize#2423
Blue-Berrys wants to merge 2 commits into
agentscope-ai:mainfrom
Blue-Berrys:fix/2303-remote-snapshot-rebind

Conversation

@Blue-Berrys

@Blue-Berrys Blue-Berrys commented Jul 27, 2026

Copy link
Copy Markdown

AgentScope-Java Version

2.0.1-SNAPSHOT

Description

Fixes #2303.

RemoteSandboxSnapshot only serializes its id. After JSON round-trip, RemoteSnapshotClient is null. SandboxClient.deserializeState(json, snapshotSpec) previously ignored snapshotSpec, so only DockerSandboxClient (which overrode the two-arg method) rebound the client. AgentRun / Daytona / E2B / Kubernetes clients were affected.

Changes:

  • Move remote-snapshot rebinding into the SandboxClient interface default deserializeState(String, SandboxSnapshotSpec).
  • Remove the duplicate override from DockerSandboxClient (it now inherits the default).
  • Add SandboxClientRemoteSnapshotRebindTest covering unbound single-arg deserialize and two-arg rebind success.

Validated with:

mvn -pl agentscope-harness -am \
  -Dtest=SandboxClientRemoteSnapshotRebindTest,HarnessSandboxJacksonModuleTest \
  test

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.) — N/A (behavioral bug fix, no doc surface)
  • Code is ready for review

Default deserializeState(json, snapshotSpec) ignored the snapshot
spec, so non-Docker sandbox clients left RemoteSandboxSnapshot unbound
after JSON round-trip. Move rebinding into the interface default and
cover it with unit tests.

Fixes agentscope-ai#2303
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@CLAassistant

CLAassistant commented Jul 27, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@oss-maintainer oss-maintainer 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.

Code Review — Approved ✅

Overall: Good fix for the sandbox state deserialization issue. The PR correctly moves the rebindRemoteSnapshot logic from DockerSandboxClient to the SandboxClient interface as a default method, ensuring all sandbox client implementations properly rebind the RemoteSnapshotClient after deserialization.

Key Changes:

  1. SandboxClient.deserializeState(json, snapshotSpec) now calls rebindRemoteSnapshot to re-inject the client
  2. rebindRemoteSnapshot is a static helper that checks if the snapshot is a RemoteSandboxSnapshot and re-creates it with the client from RemoteSnapshotSpec
  3. Removed the duplicate implementation from DockerSandboxClient

Code Quality:

  • ✅ Clean refactoring — eliminates code duplication
  • ✅ Proper null checks and type guards
  • ✅ Good Javadoc explaining the rebinding rationale
  • RemoteSandboxSnapshot only persists its id across serialization, so the client must be re-injected

CI Status: ✅ All checks passed

Verdict: Well-structured fix that correctly addresses the deserialization issue.

@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.00000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...gentscope/harness/agent/sandbox/SandboxClient.java 70.00% 1 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

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.

[Bug]: RemoteSandboxSnapshot loses RemoteSnapshotClient after JSON deserialization, only DockerSandboxClient handles the re-binding

3 participants