Repository navigation
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Fixes #3110 by taking the memory family off the per-call sandbox proxy: WorkspaceManager gains memory-scoped read / append / write that route to the host runtime-data namespace when the serving filesystem is the sandbox, listMemoryFileInfos becomes the single listing home, and flush, consolidation, the watermark and the three memory tools all go through it. The diagnosis is right and the design is the correct one — reads and writes are symmetric, the routed configuration is resolved by the unified probe instead of a bare instanceof, and the 7 new cases in MemoryFlushSandboxIndependenceTest (three of which you show red on main) cover exactly the paths that regressed. Holding at COMMENT because build (ubuntu-latest) and build (windows-latest) are still pending on 1f11efe7 and mergeStateStatus is BLOCKED; the three inline notes are about storage assumptions rather than defects in the routing code.
Findings
- [Warning]
WorkspaceManager.java:280— host-side is only equivalent to the old store if the host workspace is shared across replicas; on a per-pod workspace this trades a failed post-stream write for memory that the next replica cannot see. Needs a stated durability assumption (or the mirror path used for transcripts/session trees). - [Warning]
WorkspaceManager.java:1051— listing probes thememorydirectory whileMEMORY.md, the ledgers and the watermark each probe their own path, so amemory/prefix route splits the family across two stores (ledgers on the routed backend,MEMORY.mdhost-side) andlistMemoryFilePathsstill readsMEMORY.mdthrough the sandbox proxy — the same post-lease path #3110 is about. Resolve the decision once per family and add a routed-prefix test. - [Warning]
WorkspaceManager.java:272— on upgrade the host copy does not exist yet while the old sandbox copy does, so the first call after deployment starts from empty memory and the flush cements that. Consider a one-shot adoption, or at least a log line when a memory path is absent host-side but present in the sandbox. - [Info]
WorkspaceManager.java:547—memoryFilesRouteToLiveSandboxandtaskRecordsRouteToLiveSandboxare now identical probes; either one method for both families, or per-family resolution as asked above.
Tests
Coverage is strong for the sandbox case. The two gaps map to the findings: no case where memory/ and MEMORY.md route to different backends, and no case for upgrading from a deployment whose memory only exists in an old sandbox snapshot.
Cross-repo Note
The durability assumption above is the same one #3094 (sandbox-mirror release path) and #3106 (transcript quiescence) have to answer; if memory now writes host-side while those still mirror through the sandbox, the three paths need one documented rule about what lives where.
Automated review by github-manager-bot
…dbox The fire-and-forget memory flush (and the periodic consolidation) run AFTER the agent event stream terminates - by then the sandbox lease may already be released, and every write through SandboxBackedFilesystem failed with "No active sandbox - sandbox filesystem used outside of a call context" (agentscope-ai#3110). Per-call memory extraction was silently lost in sandbox-backed deployments. Memory files (MEMORY.md, memory/*.md, the memory state) are cross-call metadata: like task records (agentscope-ai#2803), their IO must not depend on a per-call sandbox instance. Following the direction recorded on the issue (option b - sandbox-independent storage), applied to the WHOLE memory family so listing, reads and writes can never split between two stores: - WorkspaceManager gains memory-scoped IO (readMemoryFileUtf8 / appendMemoryFileUtf8 / writeMemoryFileUtf8) that routes to the host workspace whenever the filesystem serving the path is the per-call sandbox proxy (RoutedSandbox prefix routes still take over). readMemoryMd delegates to the routed read so a host-side write is never shadowed by a stale sandbox copy. - 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 files have no per-user keying in their names (MEMORY.md, memory/<date>.md), so the directory namespace is their only isolation mechanism; a multi-user workspace keeps per-user ledgers exactly as the remote-fs mode always has. With no namespace factory configured the paths resolve to the workspace root - the location the no-filesystem mode has always used. - listMemoryFileInfos: the single home for memory listing. Under a sandbox-backed filesystem it enumerates the context's namespaced host memory directory with real sizes and mtimes; otherwise it globs the filesystem layer. The unified probe resolves RoutedSandboxFilesystem configurations (a bare instanceof in the consolidator would misroute them). - MemoryFlushManager reads existing content and appends the daily ledger through the memory-scoped IO; MemoryConsolidator delegates its ledger listing entirely to listMemoryFileInfos and rewrites MEMORY.md and the state watermark through the memory-scoped IO. - The memory TOOLS join the same store: memory_save appends and memory_get / memory_search read through the memory-scoped IO, and memory_search's listing (listMemoryFilePaths) observes the same namespaced scope in its local fallback. Without this the tools would keep writing into the per-lease sandbox copy while flush appends host-side - splitting one day's ledger across two stores and keeping tool-written memories out of consolidation forever. - The shared sandbox-path probe is factored out of the task-record routing so both families use one definition. Behavior-change disclosure (sandbox-backed deployments only; local and remote filesystem modes are untouched): memory files previously lived inside per-lease sandbox snapshots, where the post-stream flush could not write at all (the bug) and in-call tool writes died with the lease. From now on the authoritative copies live host-side under the runtime-data namespace; memory accumulated inside old sandbox snapshots becomes invisible (it was already unwritable post-stream, so the loss surface is the failed writes themselves). TDD red on main (3 initial cases: no daily ledger lands, consolidation throws through the dead proxy, MEMORY.md unreachable); green after the routing. Review-round additions: memory_save lands host-side and is immediately readable back by the rest of the family (no split storage); a RoutedSandboxFilesystem-wrapping-dead-sandbox configuration consolidates correctly; and a namespaced-deployment case (non-null NamespaceFactory) asserts BOTH search discoverability AND real isolation - the daily ledger lands under workspace/<ns>/memory with no bare-root copy. Full harness suite: only pre-existing failures remain (AguiPermissionResumeTest 4/4 fails identically on pristine main - stash-verified; the known flake family covers the rest). Maintainer-bot review round (per-member anchoring): the search listing's single directory-anchored guard sent MEMORY.md's existence probe through the dead sandbox proxy whenever a memory/ prefix route was mounted (MEMORY.md is root-level and never matches that route, so its serving backend stayed the per-call sandbox). listMemoryFilePaths now anchors each family member on the backend serving its own path: the MEMORY.md existence check skips the sandbox proxy entirely (its authoritative copy is host-side), while the ledger glob follows the memory/ directory's backend (a mounted store serves it) - a routed daily ledger stays discoverable and MEMORY.md never routes post-lease IO through the proxy. Upgrade observability: a host-side read that misses while the sandbox layer still holds a copy logs a warning (the stale copy is deliberately not adopted - every post-stream write was already lost from it); post-lease the probe fails fast and is skipped silently. The durability assumption for stateless multi-replica deployments is now stated on the family read (whole family on a shared persistent backend: non-sandbox primary, or routes covering both memory/ and MEMORY.md). Two new cases: the routed-prefix family split (red on the old guard - it threw through the dead proxy) and the upgrade shape (no adoption; exactly one sandbox interaction on a host miss). Fixes agentscope-ai#3110
1f11efe to
df3e8e1
Compare
Use the memory-specific reader introduced by upstream agentscope-ai#3113 in both memory search fixtures. Preserve the success, error-looking content and no-match assertions exposed by the latest PR merge CI.
…dbox (#3113) Backport the verified fix to the 2.0.x implementation and retain its existing public contracts where the upstream kernel differs. (cherry picked from commit 269ccd1) Backport-review-patch: 7c9ecbdcd4acc4db8bad06af1daca708c2d8aadd Constraint: No AgentScope Service or SDK migration Confidence: high Not-tested: Whole-repository verification pending after lane integration
## Description Fixes #4257. Daily-memory expiration still accesses the sandbox filesystem directly after the sandbox has been released. Follow the memory I/O approach introduced in #3113: route listing and archival moves through `WorkspaceManager`, using the authoritative host memory namespace for sandbox-backed paths and retaining native move behavior for persistent filesystem routes. - Preserve the calling user's runtime-data namespace, existing path normalization, replacement semantics and backend failure results. - Process only direct date-named ledgers, not archived or nested entries returned by recursive glob implementations. - Keep per-file best-effort maintenance and report an archive only after a successful move. Handle null/failed/empty listings without preventing consolidation. - Do not change sandbox release timing or lifecycle policy. Cross-backend host/persistent moves return a failure instead of copying/deleting between stores.
Fixes #3110
Description
The fire-and-forget memory flush (and the periodic consolidation) run after the agent event stream terminates — by then the sandbox lease may already be released, and every write through
SandboxBackedFilesystemfails withNo active sandbox — sandbox filesystem used outside of a call context. Per-call memory extraction was silently lost in sandbox-backed deployments.Memory files (
MEMORY.md,memory/*.md, the memory state) are cross-call metadata: like task records (#2803), their IO must not depend on a per-call sandbox instance. Following option (b) recorded on the issue (sandbox-independent storage), applied to the whole memory family so listing, reads and writes can never split between two stores:WorkspaceManagergains memory-scoped IO (readMemoryFileUtf8/appendMemoryFileUtf8/writeMemoryFileUtf8) that routes to the host workspace whenever the filesystem serving the path is the per-call sandbox proxy;RoutedSandboxFilesystemprefix routes still take over.readMemoryMddelegates to the routed read so a host-side write is never shadowed by a stale sandbox copy.resolveRuntimeDataPath) — the same namespaced layoutRemoteFilesystemapplies to memory paths in distributed deployments. With no namespace factory the paths resolve to the workspace root, the location the no-filesystem mode has always used.listMemoryFileInfosis the single home for memory listing: under a sandbox-backed filesystem it enumerates the namespaced host memory directory (real sizes and mtimes); otherwise it globs the filesystem layer. The unified probe resolvesRoutedSandboxFilesystemconfigurations (a bareinstanceofin the consolidator would misroute them).MemoryFlushManagerreads existing content and appends the daily ledger;MemoryConsolidatorlists ledgers via the unified listing and rewritesMEMORY.mdand the state watermark — read/write symmetric on the same store (an asymmetric watermark pair would silently re-merge all historical ledgers every run).memory_saveappends andmemory_get/memory_searchread through the memory-scoped IO, and the search listing observes the same namespaced scope. Without this, tools would write into the per-lease sandbox copy while flush appends host-side — splitting one day's ledger across two stores and keeping tool-written memories out of consolidation forever.Memory files move from per-lease sandbox snapshots to the host workspace. Local and remote filesystem modes are unaffected.
readMemoryMdand memory tools no longer consult the sandbox layer — host-side copy is authoritative.memory_saveall write host-side instead of into the sandbox.workspace/<ns>/MEMORY.md,workspace/<ns>/memory/*.md(namespace omitted when noNamespaceFactory).Upgrade: memory inside old sandbox snapshots becomes invisible. Before upgrading, copy
MEMORY.mdandmemory/*.mdfrom the sandbox snapshot to the host workspace path above. After upgrading, watch forWARNlogs naming files that exist sandbox-side but not host-side — those need manual migration.Justification: the bug (#3110) already silently lost all post-stream memory writes in sandbox mode. This makes memory persistent across calls; the only net-new loss is in-call
memory_savewrites that previously landed in the sandbox.No file overlap with #3094 (sandbox-mirror release path) or #3106 (transcript quiescence) — this fix composes with both.
Test evidence (TDD)
New
MemoryFlushSandboxIndependenceTest(7 cases), red on main for the three original cases:memory_savelands host-side, immediately readable by the familyRoutedSandboxFilesystem-wrapping-dead-sandbox consolidatesworkspace/<ns>/memory, no bare-root copyFull harness suite: only pre-existing failures remain (
AguiPermissionResumeTest4/4 fails identically on pristine main — stash-verified;honorsParentMemoryConfigpair and theDynamicHookBuilderteardown are timing flakes that pass in isolation/re-run).Checklist
mvn spotless:applymvn test)getMemoryDircontract)