Class SandboxBackedFilesystem
- All Implemented Interfaces:
AbstractFilesystem,AbstractSandboxFilesystem,SandboxAware
- Direct Known Subclasses:
PinnedSandboxFilesystem
BaseSandboxFilesystem that delegates execution to a live Sandbox.
Stable proxy created once per agent bean. The live Sandbox for a call is bound
per-call on the invocation's RuntimeContext by SandboxLifecycleMiddleware and resolved here via requireSandbox(RuntimeContext) — this per-call binding takes precedence and is what keeps
concurrent distinct-session calls on the same agent bean isolated (issue #2490). The legacy
volatile sandbox field is retained only as a best-effort fallback for context-free
internal callers that resolve the filesystem with a shared empty RuntimeContext (e.g.
WorkspaceMessageBus, which carries no per-call binding).
The middleware still maintains that field via setSandbox(io.agentscope.harness.agent.sandbox.Sandbox) on acquire and clearSandboxIfCurrent(io.agentscope.harness.agent.sandbox.Sandbox) on release, so it remains last-writer-wins under concurrency and must not
be relied on for isolation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclearSandboxIfCurrent(Sandbox expected) Clears the fallbacksandboxfield only if it still points atexpected.downloadFiles(io.agentscope.core.agent.RuntimeContext runtimeContext, List<String> paths) Download multiple files.execute(io.agentscope.core.agent.RuntimeContext runtimeContext, String command, Integer timeoutSeconds) Execute a shell command in the environment backing this filesystem.id()Unique identifier for this filesystem/sandbox instance.voidsetSandbox(Sandbox sandbox) uploadFiles(io.agentscope.core.agent.RuntimeContext runtimeContext, List<Map.Entry<String, byte[]>> files) Upload multiple files.
-
Constructor Details
-
SandboxBackedFilesystem
public SandboxBackedFilesystem()
-
-
Method Details
-
setSandbox
- Specified by:
setSandboxin interfaceSandboxAware
-
getSandbox
- Specified by:
getSandboxin interfaceSandboxAware
-
clearSandboxIfCurrent
Clears the fallbacksandboxfield only if it still points atexpected. Used bySandboxLifecycleMiddlewareon release so a finishing call never nulls a concurrent sibling call's fallback binding (issue #2490).- Parameters:
expected- the sandbox this call bound at acquire time
-
id
Description copied from interface:AbstractSandboxFilesystemUnique identifier for this filesystem/sandbox instance.- Specified by:
idin interfaceAbstractSandboxFilesystem- Specified by:
idin classBaseSandboxFilesystem- Returns:
- id string
-
execute
public ExecuteResponse execute(io.agentscope.core.agent.RuntimeContext runtimeContext, String command, Integer timeoutSeconds) Description copied from interface:AbstractSandboxFilesystemExecute a shell command in the environment backing this filesystem.- Specified by:
executein interfaceAbstractSandboxFilesystem- Specified by:
executein classBaseSandboxFilesystem- Parameters:
runtimeContext- per-call agent context; may benullwhen unavailablecommand- full shell command string to executetimeoutSeconds- maximum time in seconds to wait for the command to complete;nulluses the filesystem's default timeout- Returns:
- ExecuteResponse with combined output, exit code, and truncation flag; a
non-successful response (see
ExecuteResponse.isSuccess()) means the command did not complete successfully, sooutputmust not be parsed as normal command output
-
uploadFiles
public List<FileUploadResponse> uploadFiles(io.agentscope.core.agent.RuntimeContext runtimeContext, List<Map.Entry<String, byte[]>> files) Description copied from interface:AbstractFilesystemUpload multiple files.- Specified by:
uploadFilesin interfaceAbstractFilesystem- Specified by:
uploadFilesin classBaseSandboxFilesystem- Parameters:
runtimeContext- per-call agent runtime;RuntimeContext.empty()when nonefiles- list of path-to-content mappings to upload- Returns:
- list of FileUploadResponse objects, one per input file (order matches input order)
-
downloadFiles
public List<FileDownloadResponse> downloadFiles(io.agentscope.core.agent.RuntimeContext runtimeContext, List<String> paths) Description copied from interface:AbstractFilesystemDownload multiple files.- Specified by:
downloadFilesin interfaceAbstractFilesystem- Specified by:
downloadFilesin classBaseSandboxFilesystem- Parameters:
runtimeContext- per-call agent runtime;RuntimeContext.empty()when nonepaths- list of file paths to download- Returns:
- list of FileDownloadResponse objects, one per input path (order matches input order)
-