Skip to content

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

Open
Buktal wants to merge 1 commit into
agentscope-ai:mainfrom
Buktal:fix/sandbox-resume-stale-workspace-spec
Open

fix(sandbox): use updated WorkspaceSpec when resuming from persisted state#1928
Buktal wants to merge 1 commit 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

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 Buktal requested a review from a team June 26, 2026 03:38
…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 force-pushed the fix/sandbox-resume-stale-workspace-spec branch from a85ecbd to 1d03843 Compare June 26, 2026 03:39
@itxaiohanglover

Copy link
Copy Markdown
Contributor

Nice fix — the null check on workspaceSpec and the defensive .copy() are solid. One thing I noticed: it'd be great to have a unit test covering the resume path to make sure the stale spec actually gets overwritten. Other than that, looks good to me.

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

2 participants