Repository navigation
fix(harness): classify sandbox-backed overlays for skill shell paths - #2567
jaideeppyne wants to merge 8 commits into
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Rebase complete (conflict resolved)Rebased onto latest Resolution
Evidence
|
aab9675 to
69f07a8
Compare
Conflict resolution statusConflict with A rebased fix is ready locally and validated: Resolution shape (on top of current public String resolveOffloadPath(RuntimeContext rc, String agentId, String sessionId) {
if (workspaceManager.getFilesystem() instanceof AbstractSandboxFilesystem) {
return "";
}
return new SessionTranscriptWriter(workspaceManager)
.resolveContextPath(rc, agentId, sessionId);
}Local-path test expects workspace-relative path Push blocked: OAuth token lacks |
69f07a8 to
2ea4891
Compare
Rebased and force-pushedConflict with Resolution
Local validation
|
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
This PR modifies 2 files with 74 lines of diff.
Observations
- Files changed: 2
- Test coverage: ✅ Tests included
- CLA: ✅ Signed
Suggestions
- Please ensure all public API changes are backward compatible
- Consider adding unit tests for new logic paths
Automated review by github-manager-bot
|
Thanks for the review. To confirm on the two suggestions: the change is backward compatible — |
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
This PR adds a sandbox-aware guard to the deprecated MemoryFlushManager.resolveOffloadPath method, returning an empty string when the workspace filesystem is backed by a sandbox. The intent is correct: sandboxed agents cannot resolve host-side workspace paths, so advertising them in the compaction summary prompt is misleading. The fix is minimal, well-commented, and includes two unit tests covering both the sandbox and local-filesystem paths. However, the guard is applied only to the deprecated method — the recommended replacement (SessionTranscriptWriter.resolveContextPath) has no equivalent protection, creating a migration hazard.
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Delta re-review after 42e8ba7b (propagate the guard into SessionTranscriptWriter). The direction is right — a host-side archive path is not resolvable from inside a container, and advertising it in the compaction summary sends sandboxed agents chasing a file they cannot open. But the chosen predicate, getFilesystem() instanceof AbstractSandboxFilesystem, is a shell-capability marker rather than an isolation marker, so it also matches the plain local-with-shell workspace (LocalFilesystemSpec → ShellAwareOverlay/ProjectAwareOverlay), where the path is host-readable. That is flagged inline as the one blocking point; two smaller ones follow.
Verdict
COMMENT — one over-match to settle before merge (SessionTranscriptWriter.java:175); the rest is non-blocking. CLA signed, tests included for both branches of the new rule.
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Delta re-review after 42e8ba7b → 851d9ff7 (distinguish sandbox storage from local shell overlays). The motivation is correct and my previous blocking point is fixed: LocalFilesystemWithShell implements AbstractSandboxFilesystem purely as a shell-capability marker, so the old interface check hid a host-readable path from local-dev workspaces that can resolve it fine, and the two new OverlayFilesystem.of(...) test cases pin that behaviour properly. Removing the duplicated guard from the deprecated MemoryFlushManager.resolveOffloadPath in favour of the single delegate is also the right consolidation.
One issue holds this back: the replacement predicate is now too narrow in the opposite direction. RoutedSandboxFilesystem implements AbstractSandboxFilesystem without extending BaseSandboxFilesystem, and HarnessAgent uses it as the workspace filesystem for any sandboxed agent that declares file routes — so for sandbox + filesystemRoutes the host-side archive path is advertised to the agent again, which is the leak this PR was written to plug. The repo already solves this shape twice (HarnessAgent shell-policy selection and WorkspaceManager.taskRecordsRouteToLiveSandbox both unwrap RoutedSandboxFilesystem.primary() / .backendFor(...)), so I have suggested a shared sandboxBacked(...) predicate instead of a fourth hand-rolled instanceof chain.
Findings
- [Warning]
SessionTranscriptWriter.java:174—instanceof BaseSandboxFilesystemmissesRoutedSandboxFilesystem(andOverlayFilesystem.ShellAwareOverlay), re-advertising the host path for sandboxed agents with file routes; suggest one shared unwrapping predicate - [Info]
MemoryFlushManagerOffloadTest.java:62— the local-overlay branch is now covered, but the routed-sandbox branch (the case that regressed) has no test, which is why the narrowing is green
Verdict
COMMENT — non-blocking on its own if you can confirm filesystemRoutes + sandbox is not a supported combination for HarnessAgent; if it is, the unwrapping helper is a small change and the missing test would have caught it. CLA signed (license/cla=success on 851d9ff7), CI green on this head (ubuntu + windows + codecov/patch).
Automated review by github-manager-bot
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Delta re-review after 851d9ff7 → 389685ce ("classify wrapped sandbox filesystems consistently"). The blocking point from the previous round is resolved: FilesystemUtils.isSandboxBacked now unwraps RoutedSandboxFilesystem.primary() and OverlayFilesystem.getUpper(), so a routed sandbox with file routes is no longer classified as host-readable, and the predicate is shared with the HarnessAgent shell-policy branch instead of being re-derived per call site. The routed case is also pinned by resolveOffloadPath_omitsHostPathForRoutedSandboxFilesystem. CI is green on ubuntu + windows and CLA is signed.
What is left is a scope question rather than a correctness bug: the guard suppresses the pointer for the common case too. resolveContextPath returns a workspace-relative path whenever the archive is under the workspace, and SessionTree.scheduleMirror() uploads exactly that relative path into the live (sandbox) filesystem — so a sandboxed agent can open it, while only the absolute-path fallback is genuinely unresolvable. Flagged inline with two ways to settle it. Two smaller points follow: route-awareness of primary() versus backendFor(relPath), and the HarnessAgent branch, which is a behavior change that arrives without a test.
Verdict
COMMENT — no blocking defect found; the four inline points are about narrowing the suppression and covering the HarnessAgent classification change. CLA signed, so this stays a comment rather than an approval only because the first point is a real behavior question for the author to answer.
Automated review by github-manager-bot
|
Follow-up on the 2026-09-19 review, in 74e077b:
Focused Maven run: |
…lveContextPath The deprecated MemoryFlushManager.resolveOffloadPath now hides the host-side offload path from sandboxed agents, but its recommended replacement, SessionTranscriptWriter.resolveContextPath, still resolved and returned that host path unconditionally. Callers migrating to the recommended method would lose the protection. Propagate the same AbstractSandboxFilesystem guard to resolveContextPath so it returns an empty string for sandbox-backed filesystems, and add parallel SessionTranscriptWriterTest coverage for both the sandbox (empty) and local (reachable path) cases. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Hide only the absolute host fallback from sandboxed agents. Classify a session path by the backend that serves it, and test overlay-sandbox shell-policy selection directly.
|
Rebased onto current main after the review follow-up conflicted in
|
74e077b to
3a8b8b6
Compare
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Delta re-review of 389685ce → 3a8b8b60a8 (commits 3ac00709, ad0c3be0, 4839310b, 5ea4a20b, 3a8b8b60). All three inline points from the previous round are settled. 3a8b8b60a resolves the main scope question: SessionTranscriptWriter.resolveContextPath now keeps the workspace-relative pointer whenever the archive sits under the workspace (which SessionTree.scheduleMirror() uploads into the live filesystem, so a sandboxed agent can open it) and hides only the absolute host fallback, and only when the backend that serves the session path is sandbox-backed — exactly the narrower guard the previous review asked for. The same commit adds a route-aware FilesystemUtils.isSandboxBacked(filesystem, relPath) overload that resolves backendFor(relPath) for routed filesystems, and extracts HarnessAgent.Builder.selectShellPathPolicy with direct coverage in the new HarnessAgentShellPathPolicyTest, which also pins the previously untested behavior change (overlay with sandbox upper now selects ShellPathPolicy.sandbox instead of falling through to noShell — correct, since ShellAwareOverlay runs execute on the sandbox). No blocking defect found in this delta; one info-level note remains on the depth-cap fail-open in the classifier.
Delta vs previous review
- Resolved — common-case pointer suppression.
resolveContextPath(SessionTranscriptWriter.java:175-198) returns the relative path whenfileis under the workspace before any sandbox classification, and suppresses only the absolutefile.toString()fallback. The mirror claim is verified in code:SessionTree.scheduleMirror()uploads the context file at its workspace-relative path viauploadFilesinto the live filesystem, and the un-namespaced relative path built by the newsessionContextRelativePathhelper matches the convention already used inSessionTranscriptWriter.appendMessages(lines 94-102), so the advertised pointer is the path the mirror actually writes. Downstream is safe too:ConversationCompactormaps a blank result tonull(no file reference). - Resolved —
primary()vsbackendFor(relPath). The transcript guard uses the route-aware overload; theHarnessAgentshell-policy branch intentionally keeps the non-route-aware form, which is consistent becauseRoutedSandboxFilesystem.executealways delegates toprimary(). - Resolved — untested
HarnessAgentclassification change.selectShellPathPolicyis a faithful extraction (the literalfalseat the call site is safe becauseshellToolAvailablealready implies!disableShellTool), andHarnessAgentShellPathPolicyTestcovers sandbox overlay, routed primary, local-shell overlay, and disabled-shell cases againstShellPathPolicy.resolve's actual formats. - Non-blocking note: the relative pointer can dangle transiently if the fire-and-forget mirror upload has not completed when the agent follows the reference — that race is inherited from the pre-existing async mirror design, not introduced by this round.
Findings
agentscope-harness/src/main/java/io/agentscope/harness/agent/filesystem/util/FilesystemUtils.java:73(info) — Depth cap fails open: >8 wrappers (or a cycle) classify as not sandbox-backed, which would re-expose the absolute host fallback to a sandboxed agent; documented and unreachable at current wrap depths, but the cap's outcome is untested.
Verification
- Read at HEAD:
FilesystemUtils,SessionTranscriptWriter(+appendMessagesconvention),MemoryFlushManager(net diff vs base9b611928eis empty — the interim guard was added then removed cleanly),RoutedSandboxFilesystem(primary/backendFor),CompositeFilesystem(the delta there is pure code motion ofRouteEntry/RouteResultbelowfilesystemFor),OverlayFilesystem.of/ShellAwareOverlay,HarnessAgentbuilder region (extracted policy + call site),ShellPathPolicy,ConversationCompactor(blank → null handling),SessionTree.scheduleMirror/mirrorToFilesystem,WorkspaceManager.resolveSessionContextFile/getSessionDir, andWorkspaceConstants. - Type hierarchy confirmed:
SandboxBackedFilesystem extends BaseSandboxFilesystem;RoutedSandboxFilesystemimplementsAbstractSandboxFilesystembut notBaseSandboxFilesystem, so the unwrap inisSandboxBackedis required and present. - Ran
mvn -T1 -pl agentscope-harness -am test -Dtest='MemoryFlushManagerOffloadTest,SessionTranscriptWriterTest,HarnessAgentShellPathPolicyTest': 22 tests, 0 failures, BUILD SUCCESS. Did not run the full module suite orspotless:check.
Automated review by github-manager-bot
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Delta re-review of 3a8b8b60 → d54aeb84 (single commit "fail closed at filesystem depth limit", FilesystemUtils.java +3/-3 plus a new FilesystemUtilsTest).
The last open finding from the previous round is resolved exactly as suggested: isSandboxBacked() now returns true when the unwrap loop exceeds the 8-wrapper depth cap, so a cyclic or unexpectedly deep filesystem composition can no longer be misclassified as host-readable and leak an absolute host offload path into a sandbox agent's context. The javadoc was updated to match, and the new test pins both sides of the boundary (7-deep overlay chain → not sandbox-backed; 8th overlay → sandbox-backed).
Trade-off acknowledged: a genuinely deep non-sandbox chain (>8) will now be classified as sandbox-backed and lose the host archive-path hint — a fail-closed default that is clearly the right way round for a path-exposure guard.
All earlier inline points (depth-bound, wrapped-sandbox classification, resolveContextPath scope) were already settled in prior rounds. CLA: signed per CLAassistant ("All committers have signed the CLA"); the license/cla status is simply re-pending on the new commit. CI green on head (license, module-sync, ubuntu/windows builds, codecov).
LGTM — approved.
Automated review by github-manager-bot
…fload-path # Conflicts: # agentscope-harness/src/main/java/io/agentscope/harness/agent/HarnessAgent.java # agentscope-harness/src/main/java/io/agentscope/harness/agent/memory/session/SessionTranscriptWriter.java # agentscope-harness/src/test/java/io/agentscope/harness/agent/memory/MemoryFlushManagerOffloadTest.java # agentscope-harness/src/test/java/io/agentscope/harness/agent/memory/session/SessionTranscriptWriterTest.java
Keep sandbox-backed overlay classification on the current skill shell policy. isSandboxBacked still walks overlays and routes, and a chain deeper than eight wrappers fails closed.
|
Updated this branch onto the latest main.
|
Summary
Main has since removed the transcript-offload path entirely (the compaction redesign now references a logical
session_history(...)instead of a host file path), which independently resolves the host-path leak from #2566. After merging main, this PR is narrowed to the remaining sandbox-classification fix:FilesystemUtils.isSandboxBacked(...), which classifies a filesystem by where new files land (overlay upper layer, routed primary/prefix backend), unwrapping at most eight wrappers and failing closed for deeper chainsHarnessAgent.Builder.selectShellPathPolicy(...)and useisSandboxBackedso overlays with a sandbox upper layer getShellPathPolicy.sandbox(...)instead of falling through tonoShell()HarnessAgentShellPathPolicyTestandFilesystemUtilsTestcoverageRelated: #2566.
Validation
mvn -pl agentscope-harness -am teston the harness filesystem/agent test classes: 107 tests, 0 failures (includingHarnessAgentShellPathPolicyTest,FilesystemUtilsTest,CompositeFilesystemTest,HarnessAgentTest)mvn -q -pl agentscope-harness spotless:check: passedRisk and rollback
Behaviour changes only for sandbox-backed overlay/routed filesystems when choosing the skill shell-path policy. Local filesystems keep
localWithShell. No public API or persisted format changes; reverting restores the previous policy selection.Since the scope changed after approval, a quick re-look would be appreciated.
I used a coding agent to help write and verify this change.