Repository navigation
Description
Describe the bug
When a HarnessAgent is configured with a sandbox-backed filesystem (e.g. SandboxBackedFilesystem via the sandbox lifecycle middleware), the background maintenance threads of WorkspaceTaskRepository (ws-task-maint-*) cannot persist or read task records. The sandbox instance is injected into the filesystem only during an agent call (SandboxLifecycleMiddleware.acquireForCall → setSandbox, cleared in releaseForCall), but the heartbeat and orphan sweeper run on a standalone daemon thread with sandbox == null. As a result:
- The orphan sweeper throws
SandboxException.SandboxConfigurationException: No active sandbox — sandbox filesystem used outside of a call contextevery sweep cycle and only logs a warning, so orphaned tasks are never marked FAILED. - The heartbeat silently fails the same way (caught at
debuglevel), solastUpdatedAtis never refreshed and RUNNING tasks never progress — the whole task-liveness mechanism is broken in sandbox mode.
To Reproduce
- Configure
HarnessAgent/ReActAgentwith a sandbox-backed workspace (sandbox mode +SandboxBackedFilesystem). - Submit an async background subagent task (
timeout_seconds=0) viaAgentSpawnTool. - Observe logs every ~5 min:
[ws-task-maint-176] WARN i.a.h.a.s.t.WorkspaceTaskRepository: - Orphan sweeper encountered an error: No active sandbox — sandbox filesystem used outside of a call context
Expected behavior
Task records are cross-call orchestration metadata and must not depend on a per-call sandbox instance. The sweeper should detect and mark orphaned tasks as FAILED, and the heartbeat should refresh lastUpdatedAt even when no agent call is in progress.
Root cause (code pointers)
io.agentscope.harness.agent.filesystem.sandbox.SandboxBackedFilesystem#requireSandbox(line ~194) throws whensandbox == null.WorkspaceTaskRepository#sweepOrphanedTaskscallsWorkspaceManager#listAllTaskRecords→filesystem.glob(...)on the maintenance thread.WorkspaceManagertask-record paths (readTaskMap/persistTaskMap/listAllTaskRecords) route through the filesystem layer (readWithOverride/writeUtf8WorkspaceRelative), which requires a live sandbox.SandboxLifecycleMiddlewaresets/clears the sandbox only aroundReActAgent.beforeAgentExecution/afterAgentExecution.
Environment (please complete the following information):
- AgentScope-Java Version: latest (2.0.3-SNAPSHOT)
- Java Version: TBD
- OS: Linux
Additional context
The ControlPlaneTaskRepository (aistio) is not affected because it persists via the control-plane HTTP API and has no client-side sweeper.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(harness): route task records around the per-call sandbox proxy
fix(harness): route task records around the per-call sandbox proxy
fix(harness): route task records around the per-call sandbox proxy (a…