Skip to content

fix(sandbox): use updated WorkspaceSpec when resuming from persisted state#1927

Closed
Buktal wants to merge 8 commits into
agentscope-ai:mainfrom
Buktal:fix/sandbox-resume-stale-workspace-spec
Closed

fix(sandbox): use updated WorkspaceSpec when resuming from persisted state#1927
Buktal wants to merge 8 commits into
agentscope-ai:mainfrom
Buktal:fix/sandbox-resume-stale-workspace-spec

Conversation

@Buktal

@Buktal Buktal commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.0.0-SNAPSHOT (commit ddad83a)

Description

Background:
When an application modifies WORKSPACE_PROJECTION_ROOTS in SandboxFilesystemSpec (e.g., adding .skills-cache to the projection list), the change is ignored for existing sandboxes resumed from Redis. The sandbox continues using the old WorkspaceSpec persisted in SandboxState.

Root cause:
SandboxManager.acquire() deserializes SandboxState from Redis and directly passes it to client.resume(state). The WorkspaceSpec inside state was captured during the first create() call and is never updated.

Changes made:

  • Modified SandboxManager.acquire() (L106-109) to overwrite state.workspaceSpec with the current sandboxContext.workspaceSpec before resuming
  • This ensures application-layer configuration changes take effect without requiring manual cache deletion

How to test:

  1. Deploy an application with initial projection roots: ["A", "B", "C"]
  2. Run the application, create a sandbox (state persisted to Redis)
  3. Update projection roots to ["A", "B", "C", "D"] where D exists on host
  4. Redeploy and verify that directory D appears in the sandbox without manual cache deletion

Related:

Checklist

  • 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.)
  • Code is ready for review

Buktal added 8 commits June 18, 2026 10:09
…eStore scope-value overloads

Add a public factory method SandboxIsolationKey.of(scope, value) so that
out-of-band callers (restore, archive, scavenger) can build a key without
a RuntimeContext or guessing the internal slotSessionId format.

Add SessionSandboxStateStore.load(scope, value) / save(scope, value)
convenience overloads so that application code no longer needs to
construct SandboxIsolationKey objects manually.
…state

When SandboxManager resumes a sandbox from Redis, it now overwrites
the stale WorkspaceSpec in SandboxState with the current spec from
SandboxContext. This ensures application-layer config changes (e.g.,
adding .skills-cache to WORKSPACE_PROJECTION_ROOTS) take effect
without requiring manual cache deletion.

Fixes agentscope-ai#1926
@Buktal Buktal requested a review from a team June 26, 2026 03:33
@Buktal

Buktal commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Closing this PR - will recreate from clean main branch to avoid including unrelated commits

@Buktal Buktal closed this Jun 26, 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.

[Bug]: Sandbox resume ignores updated WorkspaceSpec configuration

1 participant