Repository navigation
Description
Describe the bug
MarketplaceStager materialises skill resources exclusively from AgentSkill.getResources() (agentscope-harness/src/main/java/io/agentscope/harness/agent/skill/runtime/MarketplaceStager.java, materializeIfChanged). When the skill comes from a FileSystemSkillRepository constructed with lazy=true, the resource map is intentionally empty (only SKILL.md is read; support files are resolved on demand through originDir).
In that case materializeIfChanged() creates the staged directory but writes zero files, while stageAll() still returns StageResult.Cached unconditionally. Consequences:
ShellPathPolicyrenders a<files-root>in the system prompt pointing to a directory that is permanently empty (silent failure — no WARN/ERROR anywhere in the staging path).- For sandboxed harness agents, workspace projection hydrates the empty
.skills-cache/<scope>/<ns>/<skill>/subtree into the container, so skill scripts (scripts/*.pyetc.) are never reachable in the sandbox, even though the skill is advertised as available.
To Reproduce
@Test
void lazyFileSystemRepo_stagesNothingButReportsCached(@TempDir Path tmp) throws Exception {
Path library = Files.createDirectories(tmp.resolve("library/my-skill/scripts"));
Files.writeString(tmp.resolve("library/my-skill/SKILL.md"),
"---\nname: my-skill\ndescription: demo\n---\nbody\n");
Files.writeString(library.resolve("gen.py"), "print('hi')\n");
var repo = new FileSystemSkillRepository(tmp.resolve("library"), false, null, /* lazy */ true);
var stager = new MarketplaceStager(tmp.resolve("workspace"));
Files.createDirectories(tmp.resolve("workspace"));
AgentSkill skill = repo.getAllSkills().get(0);
assertTrue(skill.getResources().isEmpty()); // lazy by design
var ns = new IdentityHashMap<AgentSkillRepository, String>();
ns.put(repo, repo.getSource());
var results = stager.stage(List.of(new RepoBound(skill, repo)), ns, "session-1");
Path stagedDir = tmp.resolve("workspace/.skills-cache/session-1/" + repo.getSource() + "/my-skill");
// BUG: result claims "Cached" and files-root will be rendered into the prompt,
// but the staged directory contains no files at all:
assertInstanceOf(StageResult.Cached.class, results.get("my-skill"));
try (var s = Files.walk(stagedDir)) {
assertEquals(1, s.filter(Files::isRegularFile).count()); // fails: 0 regular files
}
}Expected behavior
Either of:
MarketplaceStagerfalls back to copying fromAgentSkill.getOriginDir()(recursively, preserving relative paths) when the in-memory resource map is empty — this would also preserve binary content and exec bits better than the current String-based materialisation; orstage()returnsStageResult.NONEwhen nothing was materialised, so<files-root>is not rendered and the failure is not silent.
Reporting Cached for an empty directory is the worst of both outcomes: the model is told a path exists, and shell tools in the sandbox fail with "Path does not exist".
Error messages
None during staging (that's part of the bug). The failure only surfaces later inside the sandbox as a tool-level error, e.g.:
Error: Path does not exist: .skills-cache/<session-id>/filesystem-<ns>/my-skill
Environment
- AgentScope-Java Version: 2.0.3
- Java Version: 21
- OS: Windows 11 / Linux (platform-independent)
Additional context
There is a design mismatch between the two skill delivery paths:
- core side:
SkillBox.uploadSkillFiles()explicitly skips copying for skills with a populatedoriginDir(agentscope-core/src/main/java/io/agentscope/core/skill/SkillBox.java) — the assumption being the shell can access the host path directly via<files-root>; - harness side: for sandboxed agents the host
originDiris unreachable from inside the container, and.skills-cachestaging fromgetResources()is the only delivery route — which degenerates to an empty directory for lazy repositories.
So any lazy-mode filesystem repository + Docker/remote sandbox combination silently loses all skill script files.
Activity
oss-maintainer commentedon Sep 30, 2026
Issue Evaluation
Category:
bug| Status: Confirmed (verified againstmain@01da9e6fb,2.0.4-SNAPSHOT)All six claims hold on the current code. This is a real, silent failure on the harness skill path.
Confirmed
AgentSkill.getResources()MarketplaceStager.java:238→materializeIfChanged(stagedDir, skill.getResources()); the method body (:272-302) writes one file per map entry.originDirdoes not appear anywhere underagentscope-harness/src/mainoriginDirsetFileSystemSkillRepository.java:124(4-arg ctor),:203-204→SkillFileSystemHelper.loadSkillFromDirectory(dir, source, !lazy);SkillFileSystemHelper.java:114-117setsresources = nullandoriginDir(...), andAgentSkill.java:170turns null into an empty mapCachedreturned, no logMarketplaceStager.java:274-277—Files.createDirectories(stagedDir)then `if (resources == null<files-root>still points at the empty dirShellPathPolicy.java:100-111resolves anyCachedto a path with no emptiness check;SkillPromptBuilder.java:175-177emits<files-root>whenever non-blank, and:149-155(template:76-92) tells the model tolsand run scripts under itWorkspaceProjectionApplier.java:121tars onlyFiles::isRegularFile, so an empty skill dir contributes zero tar entries;AbstractBaseSandbox.java:277hydrates only whenpayload.fileCount() > 0. Projection roots include.skills-cache(SandboxFilesystemSpec.java:41-42)originDirskillsSkillBox.java:694-707—if (skill.getOriginDir().isPresent()) continue;, coherent with core-sideAgentSkillPromptProvider.java:316-319andSkillToolFactory.java:293-308Corrections / refinements to the report
LocalFilesystemWithShellthe same empty host path is advertised (HarnessAgent.java:2874-2911,ShellPathPolicy.java:140-148), sols <files-root>shows an empty directory without any container involved.SkillToolFactory/AgentSkillPromptProvideroriginDir fallbacks are core-only, andHarnessAgent.java:2933callsinner.dynamicSkillsEnabled(false), so none of that machinery runs underHarnessAgent.FileSystemSkillRepositoryalso does not implementLazyResourceCapable, soload_skill_through_path(skillId, "scripts/run.sh")fails too (SkillLoadTool.java:195-219,HarnessSkillMiddleware.java:289-299). The premise inLazyResourceCapable.java:30-34("the in-memory map already covers every path") is exactly whatlazy=truebreaks.materializeIfChangedreturns beforeremoveUnexpected(:301), a dir that already has files from an earlier eager configuration is left partially stale.FileSystemSkillRepository.java:124),stage(List<RepoBound>, Map<AgentSkillRepository,String>, String)(MarketplaceStager.java:147,RepoBoundat:576) and the pathworkspace/.skills-cache/session-1/<ns>/<skill>(:164,:189-206,:236) all match. One caveat: withsource == null,repo.getSource()is"filesystem-<parentDir>_<dirName>"(:264-281), so read it from the repo instead of hardcoding.Impact: any
HarnessAgentwith a shell filesystem plus a lazy repository — sandboxed or local. Skill scripts are advertised as available and unreachable. Severity: high — it is silent by construction (no WARN, andCachedasserts success), and it breaks the primary delivery channel for skill code.Fix direction
MarketplaceStager.materializeIfChanged(:272-302) — whenresourcesis empty andskill.getOriginDir()is present, copy that tree, reusing the existing path-safety checks (:286-294) and the exec-bit heuristic (:304-351). Pass the skill (or itsoriginDir) in fromstageAll(:236-244). This keepsCachedtruthful and needs noShellPathPolicychange, and fixes both sandbox and local paths at once.HarnessSkillMiddleware(:289-302) aSkillResourcesadapter overoriginDirfor non-LazyResourceCapablerepos soload_skill_through_pathworks too, and correct the staleLazyResourceCapablejavadoc.StageResult.NONEinstead ofCached(as you suggested) only stops advertising the empty path; it does not restore script access, so we would treat it as a fallback if (1) is judged too invasive.Test gap: no existing test stages a lazy repository —
MarketplaceStagerOrphanGcTest,MarketplaceStagerExecBitTest,SharedWorkspaceSkillStagingE2ETest,SkillRuntimeTest,SandboxLifecycleMiddlewareCallbackTestall use eager/stub resources, andFileSystemSkillRepositoryLazyTestnever stages. NoteSharedWorkspaceSkillStagingE2ETest.java:121-134only assertsFiles.isDirectory(advertised)— an empty directory passes it, which is why the E2E guard never caught this.Next step: we are not opening a PR unconditionally here. Fix (1) is self-contained and we are confident about it; fix (2) changes
LazyResourceCapable/SkillResourcessemantics, which is a maintainer call. @BeginnerCong if you plan to send the PR yourself we will review it — otherwise reply here and we will turn fix (1) plus tests into a proposal.Automated evaluation by github-manager-bot
xihongshichaojidan8 commentedon Sep 30, 2026
我已独立复现:同一技能在 eager 模式能缓存脚本,在 lazy 模式返回 Cached,但缓存目录为空。请问你是否已经在实现修复?如果还没有,我愿意先处理 originDir 支持文件的缓存问题,并注意与 #3314 的路径安全改动兼容。
oss-maintainer commentedon Sep 30, 2026
Evaluation follow-up |
bug| root cause confirmed — fix is now owned by the communityAnswering the question raised above: we are not implementing this fix ourselves, and we will not open a competing PR. Review stays on the PRs below.
Three open PRs currently modify the same class,
agentscope-harness/src/main/java/io/agentscope/harness/agent/skill/runtime/MarketplaceStager.java:docs/v2/{en,zh}/docs/harness/skill.mdfilesStageResult.NONEwhen nothing was materialisedAgentSkill.getOriginDir()when the resource map is emptyMapped against the fix directions in the original evaluation: #3376 is option (1) (the primary fix), #3374 is option (3) (the fallback). That ranking still holds — recovering the files is what actually makes skill scripts reachable with
lazy=trueplus a shell filesystem; returningNONEon its own only stops advertising an empty<files-root>. The two are composable: an "only reportCachedwhen something was actually written" check is still worth keeping inside option (1), for skills that have neither in-memory resources nor anoriginDir.Coordination points for whichever PR lands first:
MarketplaceStager.java, and fix(harness): prevent skill staging path traversal #3314 and fix(harness): stage lazy skill resources from origin directories #3376 touch the same two documentation files, so two of the three will need a rebase regardless of the decision. Merging fix(harness): prevent skill staging path traversal #3314 first is preferable: anyoriginDir-based recursive copy has to respect the path/namespace validation it introduces. fix(harness): stage lazy skill resources from origin directories #3376 states that symlinks inside the cache are rejected and that source/target overlap is detected through real paths — that logic should be reviewed against fix(harness): prevent skill staging path traversal #3314's rules rather than independently of them.load_skill_through_path()keeps failing for repositories that are notLazyResourceCapable(SkillLoadTool.java:195-219,HarnessSkillMiddleware.java:289-302), so alazy=trueskill stays unreadable through that tool even once staging is fixed. Closing it changesSkillResources/LazyResourceCapablesemantics, so leaving it out of both PRs was the right call — it deserves its own issue.SharedWorkspaceSkillStagingE2ETest.java:127validates the advertised path withFiles.isDirectory(advertised)only, which an empty directory satisfies — that is why this shipped unnoticed. Whichever PR is merged should additionally assert at least one staged regular file under the advertised root. (Re-checked against currentmain@addf82b89:MarketplaceStager.java:275still returns early on an empty resource map,:238/:244still reportCached, andFileSystemSkillRepositoryis still not aLazyResourceCapableimplementor.)@xihongshichaojidan8 thanks for confirming the reproduction independently. Since #3376 already covers the
originDirroute, we will treat the two submissions as complementary options for the maintainers to choose between rather than adding a third.Automated follow-up by github-manager-bot
fix(harness): report NONE when a lazy repository stages no resources (a…