Repository navigation
Open
Labels
Description
2026-10-04 09:59:54.399 [session-tree-mirror] [] WARN [i.a.h.a.f.s.SandboxBackedFilesystem] - [sandbox-fs] uploadFiles failed for path: agents/GuardedAgent/sessions/session01.log.jsonl
io.agentscope.harness.agent.sandbox.SandboxException$SandboxRuntimeException: docker tar extract failed (exit=1): Error response from daemon: container ec7e8796e3efdc83fdcef7f1098ff6702d781514c1ed1d5199a5e00c3e1ad6fc is not running
at io.agentscope.harness.agent.sandbox.impl.docker.DockerSandbox.doHydrateWorkspace(DockerSandbox.java:320)
at io.agentscope.harness.agent.sandbox.AbstractBaseSandbox.hydrateWorkspace(AbstractBaseSandbox.java:186)
at io.agentscope.harness.agent.filesystem.sandbox.SandboxBackedFilesystem.uploadFiles(SandboxBackedFilesystem.java:165)
at io.agentscope.harness.agent.memory.session.SessionTree.mirrorToFilesystem(SessionTree.java:733)
at io.agentscope.harness.agent.memory.session.SessionTree.lambda$scheduleMirror$6(SessionTree.java:593)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1090)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:614)
at java.base/java.lang.Thread.run(Thread.java:1474)
2026-10-04 09:59:57.237 [boundedElastic-1] [] WARN [i.a.h.a.m.MemoryFlushMiddleware] - Memory flush failed: No active sandbox — sandbox filesystem used outside of a call context
分析原因:
HarnessAgent.wrappedCall() 使用Mono.using() 管理 sandbox 生命周期:
- Acquire →
sandboxLifecycleMw.acquireForCall()→ 启动 Docker 容器 - Execute → Agent 执行(LLM 推理 + 工具调用),期间:
SessionTree.flush()调用scheduleMirror()提交异步上传任务到session-tree-mirror线程MemoryFlushMiddleware.onAgent()在doOnComplete中调度scheduleFlush()到boundedElastic线程
- Release → 内部 Mono 完成后,
Mono.using()cleanup 立即执行 :filesystemProxy.clearSandboxIfCurrent()→ 清除 sandbox 引用sandboxManager.release()→sandbox.stop()→ Docker 容器被停止
- 异步任务在容器停止后执行 :
session-tree-mirror线程:PinnedSandboxFilesystem持有已停止容器的引用 →hydrateWorkspace()→docker tar extract→ 报错container is not runningboundedElastic-2线程:MemoryFlushMiddleware.doFlush()→writeMemoryFiles()→workspaceManager.appendUtf8WorkspaceRelative()→filesystem.uploadFiles()→requireSandbox()找不到 sandbox → 报错No active sandbox
Activity
oss-maintainer commentedon Oct 4, 2026
Issue Evaluation
Category:
bug| Status: Confirmed | Severity: medium-high (silent persistence loss + noisy WARN stack traces) | Fix: needs maintainer decision — no PR raised yetBoth failure modes in your log reproduce from the code paths on
main(a3798a8f5). Your root-cause analysis is correct; here is the precise mapping, plus one detail worth adding.1.
session-tree-mirror→container ... is not runningHarnessAgent.wrappedCall(HarnessAgent.java:955-970) wraps the call inMono.using(...), whose cleanup runssandboxLifecycleMw.releaseForCall(...)the moment the inner Mono terminates.SandboxLifecycleMiddleware.releaseForCall(:162-190) →SandboxManager.release(SandboxManager.java:184-212) callssandbox.stop()andsandbox.shutdown()for self-managed results; Dockershutdown()removes the container.SessionTree.scheduleMirror(SessionTree.java:583-597) submits the upload to a process-wide single-thread daemon executor (:94) and pins the sandbox first viapinIfSandbox→new PinnedSandboxFilesystem(sb)(:605). The pin deliberately survivesclearSandboxIfCurrent(it is a no-op there,PinnedSandboxFilesystem.java:42), so the task keeps writing into a container that has already been stopped.SandboxBackedFilesystem.uploadFiles→active.hydrateWorkspace(...)(SandboxBackedFilesystem.java:165) →AbstractBaseSandbox.hydrateWorkspace(AbstractBaseSandbox.java:186) →DockerSandbox.doHydrateWorkspace, whose exit-code check throwsSandboxRuntimeException("docker tar extract failed (exit=...)")atDockerSandbox.java:334in currentmain(line 320 in the v2.0.3 build in your trace) — exactly your stack trace. Notestop()only flipsrunningtofalseand persists the snapshot (AbstractBaseSandbox.java:132-141); the container itself is destroyed byshutdown(), and nothing in this path consultsSandbox.isRunning()before exec'ing into it. The failure is swallowed aslog.warn("[sandbox-fs] uploadFiles failed for path: ...")(SandboxBackedFilesystem.java:169).This is not unknown to the code —
PinnedSandboxFilesystem's own javadoc says: "Self-managed sandboxes that stop on release may still fail if the async upload races past shutdown." The pin fixed the unbind race (issue #2490 / #2849) but not the container lifetime race.2.
boundedElastic→Memory flush failed: No active sandboxMemoryFlushMiddleware.onAgent(:161-167) schedules the flush fromdoOnComplete, i.e. after the inner source completes but beforeMono.usingcleanup runs;runFlush(:212-219) hops toSchedulers.boundedElastic(), so it almost always executes after release.releaseForCallhas both nulled the per-call binding (ctx.put(SandboxAcquireResult.class, null)) and cleared the proxy viaclearSandboxIfCurrent(:175), sorequireSandboxfinds neither and throwsSandboxConfigurationException("No active sandbox — sandbox filesystem used outside of a call context")(SandboxBackedFilesystem.java:239-252).doFlush→MemoryFlushManager.writeMemoryFiles(:225-239) →WorkspaceManager.appendUtf8WorkspaceRelative(:370) →filesystem.uploadFiles→requireSandbox. Logged only aslog.warn("Memory flush failed: {}", ...)(MemoryFlushMiddleware.java:219,283).Impact: the session mirror (
agents/<agent>/sessions/<session>.log.jsonl) and the extracted long-term memory (memory/*.md) are the write-behind records of a call. When they fail, the conversation answer is returned normally, but the transcript/memory is not persisted to the sandbox workspace — a silent data-loss surface, not just log noise. UnderIsolationScope.AGENT/GLOBALthe slot is shared, so a later session resuming it would see the gap too (inference from the isolation-key model inSandboxIsolationKey, not reproduced here).Duplicates / related (open): this combines two already-reported gaps — #3110 (memory flush after sandbox close, same
No active sandboxmessage) and #3036 (SessionTreemirror outliving the sandbox), both traced back to the per-call binding work in #2490/#2849.Fix directions — needs a maintainer call, so we are not auto-generating a PR:
SessionTree.awaitMirrorQuiescence(...)andMemoryBackgroundTasks.awaitQuiescence(...)inreleaseForCallbeforesandboxManager.release(...). Both helpers already exist but are wired only intoHarnessAgent.close()(:455-470), not into the per-call path. Needs a bounded timeout, and becauseMIRROR_EXECUTORis a static process-wide single thread, a per-call drain couples unrelated sessions together (call N waits on call M's uploads) — that trade-off is the real design question.PinnedSandboxFilesystem/SandboxBackedFilesystem.uploadFilescheckSandbox.isRunning()(Sandbox.java:55,AbstractBaseSandbox.java:161) and, when the sandbox is already stopped, route the payload to a durable fallback (host workspace /TranscriptStore) instead ofdocker exec, or drop it with an explicit counter rather than a WARN stack trace.Also worth noting:
runFlushreads the per-callRuntimeContextafter the call is over, so even fixing the sandbox lifetime leaves the flush depending on state thatreleaseForCallmutates (issue #2849 describes the same class of residual race). Whatever direction is chosen should cover both callers, not only the mirror.Repro conditions from your report (Docker sandbox, self-managed lifecycle,
GuardedAgentwith session logging + memory flush) match the code path, so this is reproducible without extra information. If you can share whether the session/memory files are missing on disk afterwards (vs. only the WARN), that would confirm the impact scope for item 2 above.Automated evaluation by github-manager-bot