You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]:现在的记忆是异步写入,会有问题,写入的时候沙箱已经关闭,就会警告memory flush failed: no active sandbox, sandbox filesystem used outside of call context #3110
Verified against current main (c5db8f7). The report matches the code: the memory flush is scheduled as a fire-and-forget background task, while the sandbox lease is released as soon as the agent event stream terminates — the async write can therefore run after the sandbox is gone and fail with No active sandbox — sandbox filesystem used outside of a call context.
Root Cause:MemoryFlushMiddleware hooks the flush in doOnComplete and subscribes the actual I/O on Schedulers.boundedElastic() (agentscope-harness/.../middleware/MemoryFlushMiddleware.java:159,203-211). The sandbox is released via Flux.using cleanup in HarnessAgent (HarnessAgent.java:994-1007), and SandboxLifecycleMiddleware.releaseForCall clears the SandboxAcquireResult context binding (SandboxLifecycleMiddleware.java:151-177). The later write through MemoryFlushManager.writeMemoryFiles → WorkspaceManager.appendUtf8WorkspaceRelative → SandboxBackedFilesystem.requireSandbox then throws (SandboxBackedFilesystem.java:239-255).
Impact: In sandbox-backed deployments, per-call memory extraction/consolidation can be silently lost after the call completes (memory ledgers, session offloads), with Memory flush failed warnings in logs.
Severity: high
Possible directions: (1) block on in-flight flush tasks before releasing the sandbox (e.g. drain the flush future inside Flux.using cleanup), or (2) copy the needed memory payload into a sandbox-independent buffer before flush so the persisted write no longer depends on the closed sandbox.
A maintainer replying /approve here will trigger generation of an automated fix proposal (spec + PR).
Adjacent-PR advisory (no change to the evaluation above)
Draft PR #3106 (fix(harness): avoid blocking stream completion on transcript persistence, author ningmao-hlyz, opened 2026-09-11) applies option (1) from the evaluation — keep sandbox-backed work in the stream until the async write finishes — but to transcript persistence, and it fixes #3059 rather than this issue. It touches MemoryBackgroundTasks, SessionTranscriptWriter and TranscriptMiddleware; no file overlap with the memory-flush path cited in the evaluation (MemoryFlushMiddleware, MemoryFlushManager, SandboxLifecycleMiddleware, HarnessAgent).
Consequence: the memory-flush race reported here stays unfixed even if #3106 merges. If #3106 lands first, a fix for this issue should reuse its MemoryBackgroundTasks quiescence pattern instead of adding a second drain mechanism.
This is supplementary context only — the evaluation and its proposed directions are unchanged.
Adjacent-PR collision advisory (no change to the evaluation above)
A duplicate-fix scan of all open PRs (self-authored PRs excluded, 104 open) found active work on the same sandbox-async-write-after-release race reported here:
fix(harness): support asynchronous memory flush #2833fix(harness): support asynchronous memory flush (author guslegend0510, OPEN, CONFLICTING) — edits MemoryFlushMiddleware.java and HarnessAgent.java and adds opt-in MemoryConfig.asyncFlush(true), i.e. it institutionalises the fire-and-forget flush that produces this failure without draining it before lease release.
Consequence for the /approve offer above: a generated fix would collide in SandboxLifecycleMiddleware / SandboxBackedFilesystem / HarnessAgent with #3094 and #2833, which is exactly the duplicate-fix collision our supersession notices close windows elsewhere to avoid. We are not closing this window — none of the four PRs fixes the reported failure: #3094/#3039 drain only session-mirror tasks, #3106 only transcript writes, and #2833 makes the flush asynchronous without draining it before lease release — but we will not file a competing PR unless the community tells us which seam to build on.
Preferred decision for anyone replying: (a) extend #3094's SandboxMirrorReleaseCoordinator to cover memory-flush tasks, or (b) take direction (2) from the evaluation above — copy the payload into a sandbox-independent buffer before flush — which is collision-free against all four PRs. Option (b) is the only one that can land without a merge conflict against #3094/#2833.
This is supplementary context only — the evaluation and its proposed directions are unchanged, and the reply window stays open.
I support Option (b) — copying the memory payload into a sandbox-independent buffer before flush. This avoids conflicts with #3094 and #2833 while fixing the root cause.
Reply-window advisory — option preference recorded, no change to the evaluation above
Thanks @BEN5890 — noted that option (2)/(b) (snapshot the memory payload into a sandbox-independent buffer before the flush, instead of draining in-flight tasks before the lease release) is the preferred shape. That is the first reply on this window, and it is recorded as reporter preference, not as an approval to generate code: the offer in the evaluation comment above asks a maintainer to approve explicitly, so this window stays open unchanged.
Two collision facts refreshed against current main (c5db8f72), both of which bear on that choice:
fix(harness): support asynchronous memory flush #2833 (support asynchronous memory flush, still OPEN / CONFLICTING) does edit MemoryFlushMiddleware.java, i.e. the same file a payload-snapshot fix would touch. So "collision-free against all four PRs" needs one qualifier: option (b) is the lowest-overlap shape, but if fix(harness): support asynchronous memory flush #2833 lands first the snapshot should be built inside its asyncFlush path rather than as a second parallel mechanism.
Summary: the seam question is effectively answered (option b), #3094 does not cover this report, and the only remaining blocker to an automated proposal is an explicit maintainer approval on this thread. This is supplementary context only — the evaluation and its directions are unchanged, and the reply window stays open until 2026-09-15T02:05Z.
I've opened a fix following option (b) — the direction recorded above as the preferred shape: memory-file IO is routed to a sandbox-independent host-side store whenever the filesystem serving those paths is the per-call sandbox proxy, mirroring the treatment task records received in #2803.
Branch: birdie7761/agentscope-javafix/3110-memory-flush-sandbox-independent — PR incoming right after this comment.
Design decisions worth flagging up front:
Whole-family routing: flush, consolidation, and the memory tools (memory_save / memory_get / memory_search) all go through one memory-scoped IO surface, so listing, reads and writes can never split between the sandbox copy and the host store.
User isolation is preserved: the host-side location is the context's runtime-data namespace (resolveRuntimeDataPath) — the same namespaced layout RemoteFilesystem applies to memory paths in distributed deployments. Memory filenames carry no per-user keying, so the directory namespace is their only isolation mechanism.
The consolidation watermark read/write pair is symmetric on the same store (an asymmetric pair would have silently re-merged all historical ledgers on every run).
Status: 72 h feedback window expired — no automated PR will be generated, this proposal window here is closed
The evaluation above went 72 hours without an /approve, /revise or /reject, so per our workflow the window is closed and no competing PR will be generated. No action is needed from anyone.
That turned out to be the easy case, because the direction recorded in this thread was picked up by the community:
As of this check #3113 is MERGEABLE with reviewDecision=APPROVED and a green check rollup (build ubuntu-latest / build windows-latest, Check License, Check Module Sync, license/cla) at head df3e8e1e5. #3113 stays the active path for this issue and needs a maintainer to merge it, not another implementation.
Thanks @BEN5890 for stating the option preference and @birdie7761 for building it. If maintainers would still like an independent second proposal here, say so on this issue and we will re-evaluate.
Activity
oss-maintainer commentedon Sep 12, 2026
Issue Evaluation
Category:
bug| Status: ConfirmedVerified against current
main(c5db8f7). The report matches the code: the memory flush is scheduled as a fire-and-forget background task, while the sandbox lease is released as soon as the agent event stream terminates — the async write can therefore run after the sandbox is gone and fail withNo active sandbox — sandbox filesystem used outside of a call context.Root Cause:
MemoryFlushMiddlewarehooks the flush indoOnCompleteand subscribes the actual I/O onSchedulers.boundedElastic()(agentscope-harness/.../middleware/MemoryFlushMiddleware.java:159,203-211). The sandbox is released viaFlux.usingcleanup inHarnessAgent(HarnessAgent.java:994-1007), andSandboxLifecycleMiddleware.releaseForCallclears theSandboxAcquireResultcontext binding (SandboxLifecycleMiddleware.java:151-177). The later write throughMemoryFlushManager.writeMemoryFiles→WorkspaceManager.appendUtf8WorkspaceRelative→SandboxBackedFilesystem.requireSandboxthen throws (SandboxBackedFilesystem.java:239-255).Impact: In sandbox-backed deployments, per-call memory extraction/consolidation can be silently lost after the call completes (memory ledgers, session offloads), with
Memory flush failedwarnings in logs.Severity: high
Possible directions: (1) block on in-flight flush tasks before releasing the sandbox (e.g. drain the flush future inside
Flux.usingcleanup), or (2) copy the needed memory payload into a sandbox-independent buffer before flush so the persisted write no longer depends on the closed sandbox.A maintainer replying
/approvehere will trigger generation of an automated fix proposal (spec + PR).Automated evaluation by github-manager-bot
oss-maintainer commentedon Sep 12, 2026
Adjacent-PR advisory (no change to the evaluation above)
Draft PR #3106 (
fix(harness): avoid blocking stream completion on transcript persistence, authorningmao-hlyz, opened 2026-09-11) applies option (1) from the evaluation — keep sandbox-backed work in the stream until the async write finishes — but to transcript persistence, and it fixes #3059 rather than this issue. It touchesMemoryBackgroundTasks,SessionTranscriptWriterandTranscriptMiddleware; no file overlap with the memory-flush path cited in the evaluation (MemoryFlushMiddleware,MemoryFlushManager,SandboxLifecycleMiddleware,HarnessAgent).Consequence: the memory-flush race reported here stays unfixed even if #3106 merges. If #3106 lands first, a fix for this issue should reuse its
MemoryBackgroundTasksquiescence pattern instead of adding a second drain mechanism.This is supplementary context only — the evaluation and its proposed directions are unchanged.
Automated evaluation by github-manager-bot
oss-maintainer commentedon Sep 12, 2026
Adjacent-PR collision advisory (no change to the evaluation above)
A duplicate-fix scan of all open PRs (self-authored PRs excluded, 104 open) found active work on the same sandbox-async-write-after-release race reported here:
fix(harness): defer self-managed sandbox shutdown until session mirroring completes(authorxy-ygz, OPEN, MERGEABLE) — addsSandboxMirrorReleaseCoordinatorwith refcounted sandbox release and touches two of the exact classes cited in the root cause above:SandboxLifecycleMiddleware.javaandSandboxBackedFilesystem.java. It closes [Bug]: SessionTree mirror NPEs when it outlives the sandbox — PinnedSandboxFilesystem cannot know the pinned sandbox is closed (regression from #2946, v2.0.3) #3036 (the NPE variant of the same race); the memory-flush call path named above is not in its file set, so it does not close this issue — but direction (1) ("drain in-flight work before releasing the sandbox") is already implemented there for the session-mirror path.fix(harness): support asynchronous memory flush(authorguslegend0510, OPEN, CONFLICTING) — editsMemoryFlushMiddleware.javaandHarnessAgent.javaand adds opt-inMemoryConfig.asyncFlush(true), i.e. it institutionalises the fire-and-forget flush that produces this failure without draining it before lease release.fix(sandbox): avoid session mirrors after sandbox release(OPEN, MERGEABLE) closes the same [Bug]: SessionTree mirror NPEs when it outlives the sandbox — PinnedSandboxFilesystem cannot know the pinned sandbox is closed (regression from #2946, v2.0.3) #3036 as fix(harness): defer self-managed sandbox shutdown until session mirro… #3094 — the maintainers already have two competing shapes of the same fix.Consequence for the
/approveoffer above: a generated fix would collide inSandboxLifecycleMiddleware/SandboxBackedFilesystem/HarnessAgentwith #3094 and #2833, which is exactly the duplicate-fix collision our supersession notices close windows elsewhere to avoid. We are not closing this window — none of the four PRs fixes the reported failure: #3094/#3039 drain only session-mirror tasks, #3106 only transcript writes, and #2833 makes the flush asynchronous without draining it before lease release — but we will not file a competing PR unless the community tells us which seam to build on.Preferred decision for anyone replying: (a) extend #3094's
SandboxMirrorReleaseCoordinatorto cover memory-flush tasks, or (b) take direction (2) from the evaluation above — copy the payload into a sandbox-independent buffer before flush — which is collision-free against all four PRs. Option (b) is the only one that can land without a merge conflict against #3094/#2833.This is supplementary context only — the evaluation and its proposed directions are unchanged, and the reply window stays open.
Automated evaluation by github-manager-bot
BEN5890 commentedon Sep 12, 2026
I support Option (b) — copying the memory payload into a sandbox-independent buffer before flush. This avoids conflicts with #3094 and #2833 while fixing the root cause.
oss-maintainer commentedon Sep 12, 2026
Reply-window advisory — option preference recorded, no change to the evaluation above
Thanks @BEN5890 — noted that option (2)/(b) (snapshot the memory payload into a sandbox-independent buffer before the flush, instead of draining in-flight tasks before the lease release) is the preferred shape. That is the first reply on this window, and it is recorded as reporter preference, not as an approval to generate code: the offer in the evaluation comment above asks a maintainer to approve explicitly, so this window stays open unchanged.
Two collision facts refreshed against current
main(c5db8f72), both of which bear on that choice:defer self-managed sandbox shutdown until session mirroring completes) is nowAPPROVEDandMERGEABLEwithmergeStateStatus=CLEANand all checks green (Check License,Check Module Sync,build (ubuntu-latest),build (windows-latest),codecov/patch). It closes [Bug]: SessionTree mirror NPEs when it outlives the sandbox — PinnedSandboxFilesystem cannot know the pinned sandbox is closed (regression from #2946, v2.0.3) #3036 only. Its file set is the sandbox-mirror release path, not the memory-flush path named in the evaluation (MemoryFlushMiddleware→MemoryFlushManager→WorkspaceManager→SandboxBackedFilesystem.requireSandbox), so merging it would leave the failure reported here unfixed — no stand-down is owed on this issue by fix(harness): defer self-managed sandbox shutdown until session mirro… #3094.support asynchronous memory flush, stillOPEN/CONFLICTING) does editMemoryFlushMiddleware.java, i.e. the same file a payload-snapshot fix would touch. So "collision-free against all four PRs" needs one qualifier: option (b) is the lowest-overlap shape, but if fix(harness): support asynchronous memory flush #2833 lands first the snapshot should be built inside itsasyncFlushpath rather than as a second parallel mechanism.Summary: the seam question is effectively answered (option b), #3094 does not cover this report, and the only remaining blocker to an automated proposal is an explicit maintainer approval on this thread. This is supplementary context only — the evaluation and its directions are unchanged, and the reply window stays open until
2026-09-15T02:05Z.Automated evaluation by github-manager-bot
fix(harness): keep memory flush/consolidation IO off the per-call san…
fix(harness): keep memory flush/consolidation IO off the per-call san…
fix(harness): keep memory flush/consolidation IO off the per-call san…
fix(harness): keep memory flush/consolidation IO off the per-call san…
fix(harness): keep memory flush/consolidation IO off the per-call san…
fix(harness): keep memory flush/consolidation IO off the per-call san…
fix(harness): keep memory flush/consolidation IO off the per-call san…
birdie7761 commentedon Sep 12, 2026
I've opened a fix following option (b) — the direction recorded above as the preferred shape: memory-file IO is routed to a sandbox-independent host-side store whenever the filesystem serving those paths is the per-call sandbox proxy, mirroring the treatment task records received in #2803.
Branch:
birdie7761/agentscope-javafix/3110-memory-flush-sandbox-independent— PR incoming right after this comment.Design decisions worth flagging up front:
memory_save/memory_get/memory_search) all go through one memory-scoped IO surface, so listing, reads and writes can never split between the sandbox copy and the host store.resolveRuntimeDataPath) — the same namespaced layoutRemoteFilesystemapplies to memory paths in distributed deployments. Memory filenames carry no per-user keying, so the directory namespace is their only isolation mechanism.fix(harness): keep memory flush/consolidation IO off the per-call san…
oss-maintainer commentedon Sep 15, 2026
Status: 72 h feedback window expired — no automated PR will be generated, this proposal window here is closed
The evaluation above went 72 hours without an
/approve,/reviseor/reject, so per our workflow the window is closed and no competing PR will be generated. No action is needed from anyone.That turned out to be the easy case, because the direction recorded in this thread was picked up by the community:
fix(harness): keep memory flush/consolidation IO off the per-call sandbox, by @birdie7761,Fixes #3110, implemented along option (b) (copy the memory payload into a sandbox-independent buffer) as discussed above.As of this check #3113 is
MERGEABLEwithreviewDecision=APPROVEDand a green check rollup (build ubuntu-latest/build windows-latest,Check License,Check Module Sync,license/cla) at headdf3e8e1e5. #3113 stays the active path for this issue and needs a maintainer to merge it, not another implementation.Thanks @BEN5890 for stating the option preference and @birdie7761 for building it. If maintainers would still like an independent second proposal here, say so on this issue and we will re-evaluate.
Automated by github-manager-bot
fix(harness): keep memory flush/consolidation IO off the per-call san…