You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: RemoteSandboxSnapshot loses RemoteSnapshotClient after JSON deserialization, only DockerSandboxClient handles the re-binding #2303
When using a RemoteSnapshotSpec (or a subclass such as MinioSnapshotSpec), the RemoteSandboxSnapshot is serialized into SandboxState and persisted via the state store. On the next agent call, the state is deserialized from JSON via Jackson's @JsonCreator, which only reconstructs the id field but leaves the RemoteSnapshotClient field null. This causes RemoteSandboxSnapshot.isRestorable() to throw "RemoteSnapshotClient is not bound to snapshot id: ...", preventing the sandbox from starting.
Root cause
The SandboxClient interface provides a two-parameter deserializeState(String json, SandboxSnapshotSpec snapshotSpec) default method that simply delegates to the single-parameter version, ignoring the snapshotSpec:
Only DockerSandboxClient overrides this method to re-bind the snapshot client via rebindRemoteSnapshot(). All other implementations that use RemoteSnapshotSpec are affected.
Affected clients
AgentRunSandboxClient
DaytonaSandboxClient
E2bSandboxClient
KubernetesSandboxClient
InMemorySandboxClient (theoretically, but in-memory state is not persisted across restarts)
To Reproduce
Configure a sandbox with a RemoteSnapshotSpec (e.g. MinioSnapshotSpec)
Configure a state store (e.g. PgSqlAgentStateStore or JsonFileAgentStateStore)
Send an agent message that triggers sandbox usage (first call succeeds)
Send a second agent message with the same session scope (second call fails)
Expected behavior
All SandboxClient implementations that use RemoteSnapshotSpec should re-bind the RemoteSnapshotClient from the spec when deserializing state, matching the approach already in DockerSandboxClient.rebindRemoteSnapshot().
Fix reference
DockerSandboxClient already has the correct implementation:
privatestaticvoidrebindRemoteSnapshot(SandboxStatestate, SandboxSnapshotSpecsnapshotSpec) {
if (!(snapshotSpecinstanceofRemoteSnapshotSpecremoteSnapshotSpec)) {
return;
}
SandboxSnapshotsnapshot = state.getSnapshot();
if (!(snapshotinstanceofRemoteSandboxSnapshot)) {
return;
}
state.setSnapshot(
newRemoteSandboxSnapshot(remoteSnapshotSpec.getClient(), snapshot.getId()));
}
The same pattern should be applied to the affected SandboxClient implementations, or the default method in SandboxClient should be updated to perform this re-binding generically.
Environment
AgentScope-Java Version: 2.0.1-SNAPSHOT (also present in 2.0.0)
This way all existing and future SandboxClient implementations get the fix automatically, and individual overrides are only needed for custom behavior.
Hi @jujn, could you take a look when you get a chance?
This is still reproducible on current main (c416c37) with an E2B sandbox using a MinIO-backed RemoteSnapshotSpec in the harness:
First agent call: sandbox starts fine.
Second call (same user scope): fails with RemoteSnapshotClient is not bound to snapshot id: ... at RemoteSandboxSnapshot.isRestorable() → AbstractBaseSandbox.start().
We also found the same missing re-binding silently breaks snapshot persistence in the other direction: at stop(), RemoteSandboxSnapshot.persist() throws the same "not bound" error, so the workspace archive is never uploaded. This may share a root cause with the backup-on-destroy path reported in #2538.
Root cause is unchanged from the report: SandboxClient.deserializeState(json, snapshotSpec)'s default method drops the spec, and only DockerSandboxClient re-binds the client.
It looks like #2423 already implements this fix (Approach B) — approved with green CI and no merge conflicts. Could it be merged when you get a chance?
Additional evidence on current main: E2B is still affected.
E2bSandboxClient does not override deserializeState(String, SandboxSnapshotSpec), so the default method drops the spec.
A persisted E2bSandboxState holding a RemoteSandboxSnapshot deserializes with only its id; RemoteSnapshotClient is null, and isRestorable() / restore() / persist() then throw RemoteSnapshotClient is not bound to snapshot id: ....
KubernetesSandboxClient already has a local rebind override (deserializeState(json, snapshotSpec)), and DockerSandboxClient has rebindRemoteSnapshot(). E2bSandboxClient has neither.
All E2B serde tests call the single-argument deserializeState(json), so CI cannot catch this.
Repro: E2B + RemoteSnapshotSpec (or a subclass) + a state store. The first call succeeds; the second call for the same scope fails while restoring the workspace.
PR #2423 (rebind in the interface default) looks like the right general fix and would cover E2B. I am preparing an E2B-specific regression test and, if #2423 is not merged soon, a focused E2B override. Please let me know if you prefer to wait for #2423 instead of a separate E2B PR.
DockerSandboxClient and KubernetesSandboxClient already had the override.
DaytonaSandboxClient still implements only the single-argument deserializeState(String), so it inherits the default method that drops the spec. A persisted RemoteSandboxSnapshot under Daytona still deserializes with client == null and fails at isRestorable() / persist().
The E2B and AgentRun paths are fixed; this issue is not fully closed for all RemoteSnapshotSpec users.
Activity
Peng-io commentedon Jul 19, 2026
Fix approaches:
Approach A: Fix each affected
SandboxClientindividuallyOverride
deserializeState(String, SandboxSnapshotSpec)in each client, mirroringDockerSandboxClient:AgentRunSandboxClientDaytonaSandboxClient,E2bSandboxClient,KubernetesSandboxClientApply the same
rebindRemoteSnapshot()pattern fromDockerSandboxClient.Approach B: Fix in the
SandboxClientinterface default method (recommended)Move
rebindRemoteSnapshot()into the interface default so all implementations benefit automatically:This way all existing and future
SandboxClientimplementations get the fix automatically, and individual overrides are only needed for custom behavior.oss-maintainer commentedon Jul 28, 2026
fix(sandbox): rebind RemoteSnapshotClient on state deserialize
Peng-io commentedon Oct 16, 2026
Hi @jujn, could you take a look when you get a chance?
This is still reproducible on current main (c416c37) with an E2B sandbox using a MinIO-backed
RemoteSnapshotSpecin the harness:RemoteSnapshotClient is not bound to snapshot id: ...atRemoteSandboxSnapshot.isRestorable()→AbstractBaseSandbox.start().We also found the same missing re-binding silently breaks snapshot persistence in the other direction: at
stop(),RemoteSandboxSnapshot.persist()throws the same "not bound" error, so the workspace archive is never uploaded. This may share a root cause with the backup-on-destroy path reported in #2538.Root cause is unchanged from the report:
SandboxClient.deserializeState(json, snapshotSpec)'s default method drops the spec, and onlyDockerSandboxClientre-binds the client.It looks like #2423 already implements this fix (Approach B) — approved with green CI and no merge conflicts. Could it be merged when you get a chance?
fix: rebind RemoteSnapshotClient in SandboxClient default deserialize…
chcodex commentedon Oct 20, 2026
Additional evidence on current
main: E2B is still affected.E2bSandboxClientdoes not overridedeserializeState(String, SandboxSnapshotSpec), so the default method drops the spec.E2bSandboxStateholding aRemoteSandboxSnapshotdeserializes with only itsid;RemoteSnapshotClientisnull, andisRestorable()/restore()/persist()then throwRemoteSnapshotClient is not bound to snapshot id: ....KubernetesSandboxClientalready has a local rebind override (deserializeState(json, snapshotSpec)), andDockerSandboxClienthasrebindRemoteSnapshot().E2bSandboxClienthas neither.deserializeState(json), so CI cannot catch this.Repro: E2B +
RemoteSnapshotSpec(or a subclass) + a state store. The first call succeeds; the second call for the same scope fails while restoring the workspace.PR #2423 (rebind in the interface default) looks like the right general fix and would cover E2B. I am preparing an E2B-specific regression test and, if #2423 is not merged soon, a focused E2B override. Please let me know if you prefer to wait for #2423 instead of a separate E2B PR.
Peng-io commentedon Nov 11, 2026
Status update against current
main:E2bSandboxClientandAgentRunSandboxClientnow overridedeserializeState(String, SandboxSnapshotSpec)and rebind the client fromRemoteSnapshotSpec— commit c887528, which closed [Bug] E2B sandbox ignores WorkspaceSpec.root and does not rebind RemoteSnapshotClient #4080.DockerSandboxClientandKubernetesSandboxClientalready had the override.DaytonaSandboxClientstill implements only the single-argumentdeserializeState(String), so it inherits the default method that drops the spec. A persistedRemoteSandboxSnapshotunder Daytona still deserializes withclient == nulland fails atisRestorable()/persist().The E2B and AgentRun paths are fixed; this issue is not fully closed for all
RemoteSnapshotSpecusers.Two options:
fix/2303-remote-snapshot-rebind). It moves the rebind into theSandboxClientdefault method and covers every implementation, Daytona included.DaytonaSandboxClientoverride mirroringE2bSandboxClient.@chcodex which do you prefer?