fix(harness): keep persisted snapshot id when resume falls back to fresh create - #2775
Open
Buktal wants to merge 1 commit into
Open
fix(harness): keep persisted snapshot id when resume falls back to fresh create#2775Buktal wants to merge 1 commit into
Buktal wants to merge 1 commit into
Conversation
…esh create When the Priority 3 resume fails (e.g. KubernetesSandboxClient.resume() throws because its claim/pod was terminated on the previous release), the Priority 4 fresh create built a brand-new snapshot id: the workspace silently reset to the spec on every call and each previous archive was orphaned. Carry the persisted snapshot id over to the fallback sandbox so Sandbox#start() restores the workspace from the previous archive (start Branch C) and Sandbox#stop() overwrites that same archive. The snapshot is rebuilt from the current spec, so it carries a bound client regardless of how the persisted state deserialized. Fixes agentscope-ai#2771
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AgentScope-Java Version
2.0.1 (fix developed against current
main,bf7b7dae)Description
Fixes #2771.
Background. With a harness-managed sandbox (
filesystem(SandboxFilesystemSpec)) backed by the stockKubernetesSandboxClient, the workspace silently resets on every call and each snapshot archive is orphaned:create()setsclaimOwned=true, so the per-call release (stop()→shutdown()→terminate()) deletes the claim/pod at the end of every call.getSandbox(claimName)fails — the claim is gone) andSandboxManager.acquire()falls through to the Priority 4 fresh create.snapshotSpec.build(newSessionId)produces a new snapshot id: the previous archive is never referenced again, andstart()runs the fresh-init branch — all files written in previous calls are gone, with only the P3 fallback warn as a trace.The 4-branch workspace-start logic (Branch B/C restore) exists for exactly this situation but is unreachable on Kubernetes, because the resume never succeeds. Docker works because its
resume()does not require a live container.Change. In
SandboxManager.acquire(), when a persisted state was loaded but the resume failed, the fresh-create fallback now carries the persisted snapshot id over to the new sandbox (rebuilding the snapshot from the current spec, so it carries a bound client regardless of deserialization). The nextstart()then restores the workspace from the previous archive (Branch C), and the nextstop()overwrites that same archive instead of orphaning it.The fix is client-agnostic: it applies to any
SandboxClientwhose resume can fail after its backing runtime is gone.How to test. Two new unit tests in
SandboxManagerIsolationTest:priority3_resumeFails_freshCreateCarriesOverPersistedSnapshotId— resume throws → fresh create re-seedsstate.snapshotviasnapshotSpec.build(persistedId)priority3_resumeFails_noPersistedSnapshot_keepsFreshSnapshot— no persisted snapshot → fresh snapshot untouchedFull harness module suite:
mvn -pl agentscope-harness test— all passing.Checklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)