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
[Feature]: Option to keep workspace definition files (AGENTS.md, skills/, knowledge/, subagents/) read-only for agent tools #3317
AgentScope-Java is an open-source project. To involve a broader community, we recommend asking your questions in English.
Is your feature request related to a problem? Please describe.
In the remote (shared-store) filesystem mode, AGENTS.md, skills/, knowledge/ and subagents/ are routed as an overlay: a writable per-user upper layer on top of a read-only template. The built-in write_file / edit_file tools can therefore create per-user versions of these definition files, and WorkspaceContextMiddleware injects them into that user's system prompt on every later turn.
We verified this on 2.0.3 and main with a scripted model. write_file succeeded for all four paths without confirmation. In a new session the same user's system prompt contained the written AGENTS.md and knowledge text, the skill appeared in <available_skills>, and the subagent appeared too. Other users were not affected.
This matches the design for agents meant to evolve per user. For agents whose definition is owned by the application (reviewed and evaluated product agents embedded in business services), it gives the model a way to persistently change its own instructions for a user. For example, after a prompt injection through a tool result or an uploaded image. Today the only lever is to deny write_file / edit_file entirely, because FilesystemTool does not implement matchRule, so permission rules cannot target paths.
Describe the solution you'd like
Either of these would let applications keep file tools while protecting the agent definition:
A builder / filesystem-spec option to make workspace definition paths (AGENTS.md, skills/, knowledge/, subagents/, tools.json) read-only for agent tools. Framework-owned writes such as memory and tool-result eviction would be unaffected.
Path-scoped permission rules for the filesystem tools (FilesystemTool.matchRule with glob patterns, e.g. deny write_file on AGENTS.md and skills/**).
Describe alternatives you've considered
Denying write_file / edit_file with permission rules. This is what we do now, but it removes all file writing.
disableDefaultWorkspaceSkills(). It only covers skills, not AGENTS.md / knowledge / subagents.
Additional context
Related area: workspace-driven definition and evolution (docs: harness/workspace).
Category: enhancement | Status: Evaluated (all technical claims re-verified against main @ 857e3e6c) | Feasibility: feasible — option (b) reuses machinery that already exists
The premise holds. These paths are genuinely agent-writable in the shared/remote filesystem mode, and permission rules genuinely cannot target a path today.
Evidence
Definition paths are routed as overlays with a writable per-user upper layer: RemoteFilesystemSpec.java:250-284 registers AGENTS.md, MEMORY.md, tools.json as exactFileOverlay(...) and memory/, skills/, subagents/, knowledge/, plans/ as overlayRoute(...); overlayRoute/exactFileOverlay (:289-312) both return new OverlayFilesystem(upper, lower) where upper is the per-user remote layer. The lower layer is described in-place as a "read-only workspace-root template view".
The "a per-user write persists into later turns" chain is real: WorkspaceContextMiddleware.java:212-216 reads AGENTS.md / MEMORY.md / knowledge/ per turn (readAgentsMd / readMemoryMd / readKnowledgeMd) and builds the injected block from them; HarnessSkillMiddleware renders the <available_skills> block (javadoc at :63); SubagentsMiddleware.java:95,644 owns the ## Subagents section, which DynamicSubagentsMiddleware.java:160 also calls. So WorkspaceContextMiddleware is the main injector but not the only one — a guard limited to it would miss skills and subagents.
write_file / edit_file are plain delegations with no definition-path check: FilesystemTool.java:140-177.
Claim 3 confirmed exactly: FilesystemTool contains zeromatchRule overrides, and the default is ToolBase.java:244-246 → return ruleContent == null;, i.e. any non-null ruleContent never matches. Combined with PermissionEngine.java:310-316 (ruleMatches → tool.matchRule(content, input)), the tool's input path value is never passed to the engine, so path-scoped deny rules are structurally impossible today. "Deny write_file entirely" is indeed the only lever.
Claim 4 confirmed: disableDefaultWorkspaceSkills() only gates WorkspaceSkillRepository registration (HarnessAgentBuilderSupport.java:911-914); it does not affect AGENTS.md, knowledge/ or subagents/.
Assessment of the two options
Option (b) (filesystem-spec read-only knob) is the smaller change. The overlay already distinguishes a read-only template lower layer from a writable upper layer, so the policy can be expressed per-route at RemoteFilesystemSpec (and SandboxFilesystemSpec.java:41-42, which lists the same roots: AGENTS.md, skills, subagents, knowledge, .skills-cache) plus ProjectAwareOverlay.java:56-70 (WORKSPACE_PREFIXES).
The hard part of (b) is not the flag, it is exempting framework-owned writers, which write into the same areas through different classes: MemorySaveTool.java:73-80, MemoryFlushManager.java:234, MemoryConsolidator.java:302,350 (MEMORY.md, memory/), SessionTranscriptWriter.java:86-159, WorkspaceManager.java:406-437,466-497, ToolResultEvictionMiddleware.java:188-228 (large_tool_results/), WorkspaceSkillRepository.java:236-308,345-401 (skills/<name>/SKILL.md). Reads must keep working — the whole point is that these files still get injected into the prompt.
Option (a) (FilesystemTool.matchRule + glob) is more general and orthogonal, and would also close the current all-or-nothing gap for non-definition paths. Caveat: FilesystemTool is registered as a ReflectiveFunctionTool, so the override has to live on (or be delegated from) that wrapper, and ruleContent needs a defined grammar (normalized absolute vs. workspace-relative path, ** semantics) before it can be a public contract.
Recommendation: not a pure "option" choice. Ship (a) as the mechanism (path-scoped rules are useful well beyond this one use case) and (b) as a preset that installs deny rules for the definition roots, so both framework writes and prompt injection stay untouched. Scope question for a maintainer: should the framework also offer the stricter variant where the per-user upper layer for definition paths is disabled entirely (no copy-on-write), or is a tool-write block only sufficient?
Effort: medium (~2-3 days incl. tests). Suggested coverage: FilesystemToolTest (write/edit to a definition path → blocked, read still ok), RemoteFilesystemSpecTest / CompositeFilesystemTest / ProjectAwareOverlayTest (policy routing + framework writers still allowed), WorkspaceContextMiddleware*Test (injection unaffected), and PermissionEngine/ToolBaseTest for glob matching incl. skills/**.
We can draft a spec covering (a)+(b) as described if the maintainer direction is agreed.
If you have similar business needs, the ToolCallInterceptor extension point merged in #3657 can be used to address them — it lets you implement per-invocation validation, denial, rewriting, and auditing of tool calls according to your actual business requirements.
Activity
oss-maintainer commentedon Sep 27, 2026
Issue Evaluation
Category:
enhancement| Status: Evaluated (all technical claims re-verified againstmain@857e3e6c) | Feasibility: feasible — option (b) reuses machinery that already existsThe premise holds. These paths are genuinely agent-writable in the shared/remote filesystem mode, and permission rules genuinely cannot target a path today.
Evidence
RemoteFilesystemSpec.java:250-284registersAGENTS.md,MEMORY.md,tools.jsonasexactFileOverlay(...)andmemory/,skills/,subagents/,knowledge/,plans/asoverlayRoute(...);overlayRoute/exactFileOverlay(:289-312) both returnnew OverlayFilesystem(upper, lower)whereupperis the per-user remote layer. The lower layer is described in-place as a "read-only workspace-root template view".WorkspaceContextMiddleware.java:212-216readsAGENTS.md/MEMORY.md/knowledge/per turn (readAgentsMd/readMemoryMd/readKnowledgeMd) and builds the injected block from them;HarnessSkillMiddlewarerenders the<available_skills>block (javadoc at:63);SubagentsMiddleware.java:95,644owns the## Subagentssection, whichDynamicSubagentsMiddleware.java:160also calls. SoWorkspaceContextMiddlewareis the main injector but not the only one — a guard limited to it would miss skills and subagents.write_file/edit_fileare plain delegations with no definition-path check:FilesystemTool.java:140-177.FilesystemToolcontains zeromatchRuleoverrides, and the default isToolBase.java:244-246→return ruleContent == null;, i.e. any non-nullruleContentnever matches. Combined withPermissionEngine.java:310-316(ruleMatches→tool.matchRule(content, input)), the tool's inputpathvalue is never passed to the engine, so path-scoped deny rules are structurally impossible today. "Denywrite_fileentirely" is indeed the only lever.disableDefaultWorkspaceSkills()only gatesWorkspaceSkillRepositoryregistration (HarnessAgentBuilderSupport.java:911-914); it does not affectAGENTS.md,knowledge/orsubagents/.Assessment of the two options
RemoteFilesystemSpec(andSandboxFilesystemSpec.java:41-42, which lists the same roots:AGENTS.md,skills,subagents,knowledge,.skills-cache) plusProjectAwareOverlay.java:56-70(WORKSPACE_PREFIXES).MemorySaveTool.java:73-80,MemoryFlushManager.java:234,MemoryConsolidator.java:302,350(MEMORY.md,memory/),SessionTranscriptWriter.java:86-159,WorkspaceManager.java:406-437,466-497,ToolResultEvictionMiddleware.java:188-228(large_tool_results/),WorkspaceSkillRepository.java:236-308,345-401(skills/<name>/SKILL.md). Reads must keep working — the whole point is that these files still get injected into the prompt.FilesystemTool.matchRule+ glob) is more general and orthogonal, and would also close the current all-or-nothing gap for non-definition paths. Caveat:FilesystemToolis registered as aReflectiveFunctionTool, so the override has to live on (or be delegated from) that wrapper, andruleContentneeds a defined grammar (normalized absolute vs. workspace-relative path,**semantics) before it can be a public contract.Recommendation: not a pure "option" choice. Ship (a) as the mechanism (path-scoped rules are useful well beyond this one use case) and (b) as a preset that installs deny rules for the definition roots, so both framework writes and prompt injection stay untouched. Scope question for a maintainer: should the framework also offer the stricter variant where the per-user upper layer for definition paths is disabled entirely (no copy-on-write), or is a tool-write block only sufficient?
Effort: medium (~2-3 days incl. tests). Suggested coverage:
FilesystemToolTest(write/edit to a definition path → blocked, read still ok),RemoteFilesystemSpecTest/CompositeFilesystemTest/ProjectAwareOverlayTest(policy routing + framework writers still allowed),WorkspaceContextMiddleware*Test(injection unaffected), andPermissionEngine/ToolBaseTestfor glob matching incl.skills/**.We can draft a spec covering (a)+(b) as described if the maintainer direction is agreed.
Automated evaluation by github-manager-bot
xzxiaoshan commentedon Oct 21, 2026
If you have similar business needs, the
ToolCallInterceptorextension point merged in #3657 can be used to address them — it lets you implement per-invocation validation, denial, rewriting, and auditing of tool calls according to your actual business requirements.