Skip to content

fix(harness): allow SkillLoadTool in Plan Mode by promoting isReadOnly to AgentTool interface#2067

Merged
oss-maintainer merged 1 commit into
mainfrom
fix/skill-load-tool-readonly-plan-mode
Jul 9, 2026
Merged

fix(harness): allow SkillLoadTool in Plan Mode by promoting isReadOnly to AgentTool interface#2067
oss-maintainer merged 1 commit into
mainfrom
fix/skill-load-tool-readonly-plan-mode

Conversation

@chickenlj

Copy link
Copy Markdown
Collaborator

Summary

  • SkillLoadTool implements AgentTool directly (not ToolBase), so PlanModeMiddleware's readOnlyResolver — which checked instanceof ToolBase — never recognized it as read-only, blocking load_skill_through_path calls in Plan Mode.
  • Adds default boolean isReadOnly() to the AgentTool interface (returns false by default), overrides it in SkillLoadTool to return true, and updates HarnessAgent's resolver to use the interface method instead of downcasting to ToolBase.

Changes

  • AgentTool.java: add default boolean isReadOnly() returning false
  • ToolBase.java: add @Override to existing isReadOnly()
  • SkillLoadTool.java: override isReadOnly() to return true
  • HarnessAgent.java: change resolver from t instanceof ToolBase tb && tb.isReadOnly() to t != null && t.isReadOnly(); remove unused ToolBase import
  • PlanModeMiddlewareTest.java: add test verifying SkillLoadTool is permitted in Plan Mode via the toolkit-based resolver

Test plan

  • Existing PlanModeMiddlewareTest tests pass (7/7)
  • SkillLoadToolFrontmatterViewTest passes
  • New skillLoadToolIsReadOnlyAndPermittedInPlanMode test validates end-to-end: SkillLoadTool.isReadOnly() == true, toolkit resolver permits it, write_file is still denied
  • mvn spotless:check clean

Closes #2056

…y to AgentTool interface

SkillLoadTool implements AgentTool directly (not ToolBase), so PlanModeMiddleware's
readOnlyResolver — which checked `instanceof ToolBase` — never recognized it as
read-only, blocking `load_skill_through_path` calls in Plan Mode.

- Add `default boolean isReadOnly()` to AgentTool interface (returns false)
- Override isReadOnly() in SkillLoadTool to return true
- Update HarnessAgent readOnlyResolver to use AgentTool.isReadOnly() instead of
  downcasting to ToolBase
- Add @OverRide to ToolBase.isReadOnly()

Closes #2056

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Plan Mode’s “read-only tool” detection so tools that implement AgentTool directly (not ToolBase)—specifically SkillLoadTool / load_skill_through_path—can be permitted during Plan Mode when they declare themselves read-only.

Changes:

  • Add default boolean isReadOnly() to AgentTool (default false) and align ToolBase.isReadOnly() as an override.
  • Mark SkillLoadTool as read-only by overriding isReadOnly() to return true.
  • Update HarnessAgent Plan Mode resolver to use AgentTool.isReadOnly() and add a regression test covering toolkit-based resolution.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
agentscope-harness/src/test/java/io/agentscope/harness/agent/middleware/PlanModeMiddlewareTest.java Adds an end-to-end regression test ensuring SkillLoadTool is treated as read-only and permitted in Plan Mode while a mutating tool is denied.
agentscope-harness/src/main/java/io/agentscope/harness/agent/skill/runtime/SkillLoadTool.java Declares the skill-loading tool read-only via AgentTool.isReadOnly().
agentscope-harness/src/main/java/io/agentscope/harness/agent/HarnessAgent.java Updates Plan Mode’s read-only resolver to call AgentTool.isReadOnly() instead of downcasting to ToolBase.
agentscope-core/src/main/java/io/agentscope/core/tool/ToolBase.java Marks existing isReadOnly() as an @Override of the new interface method.
agentscope-core/src/main/java/io/agentscope/core/tool/AgentTool.java Introduces isReadOnly() on the interface with Javadoc and a default false implementation.

Comment on lines +106 to +107
* <p>Read-only tools are automatically permitted in restricted execution modes such as
* Plan Mode, where write operations require explicit approval.
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...c/main/java/io/agentscope/core/tool/AgentTool.java 0.00% 1 Missing ⚠️
...java/io/agentscope/harness/agent/HarnessAgent.java 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@oss-maintainer oss-maintainer merged commit ba5543a into main Jul 9, 2026
11 of 12 checks passed
@oss-maintainer oss-maintainer deleted the fix/skill-load-tool-readonly-plan-mode branch July 9, 2026 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Plan Mode增加自定义工具白名单

3 participants