Skip to content

fix(#2441): use AgentSkillRepository instead of WorkspaceSkillRepository in SkillManageTool [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH] - #2445

Open
waterWang wants to merge 2 commits into
agentscope-ai:mainfrom
waterWang:fix-2441-use-agent-skill-repository
Open

fix(#2441): use AgentSkillRepository instead of WorkspaceSkillRepository in SkillManageTool [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH]#2445
waterWang wants to merge 2 commits into
agentscope-ai:mainfrom
waterWang:fix-2441-use-agent-skill-repository

Conversation

@waterWang

Copy link
Copy Markdown

Problem

SkillManageTool is tightly coupled to WorkspaceSkillRepository, which is a filesystem-specific implementation. This means users who configure a database-backed repository (e.g. MysqlSkillRepository, PostgresSkillRepository) cannot use the skill_manage tool — the tool is hardwired to local file operations.

Root Cause

The SkillManageTool class declares its two repository fields as WorkspaceSkillRepository:

private final WorkspaceSkillRepository mainRepo;
private final WorkspaceSkillRepository draftsRepo;

This prevents the tool from being used with any AgentSkillRepository implementation that is not filesystem-based.

Changes

  1. AgentSkillRepository interface — Added three default methods:

    • readSkillFile(String skillName, String relPath) — returns null by default
    • writeSkillFile(String skillName, String relPath, String content) — returns false by default
    • deleteSkillFile(String skillName, String relPath) — returns false by default

    These methods already exist on WorkspaceSkillRepository and are used by SkillManageTool for sub-file operations (patch, write_file, remove_file). The default implementations allow other repository types to opt in or gracefully decline.

  2. SkillManageTool — Changed field types and constructor parameter types from WorkspaceSkillRepository to AgentSkillRepository:

    • private final WorkspaceSkillRepository mainRepoprivate final AgentSkillRepository mainRepo
    • private final WorkspaceSkillRepository draftsRepoprivate final AgentSkillRepository draftsRepo
    • All 5 constructors updated to accept AgentSkillRepository
    • locate() method return type updated
    • All method-local variable types updated

Compatibility

  • WorkspaceSkillRepository implements AgentSkillRepository (via RuntimeContextSkillRepository), so all existing code continues to work without any changes to HarnessAgent or ProposeSkillTool.
  • Database-backed repositories can now be passed to SkillManageTool directly. Sub-file operations (patch, write_file, remove_file) will return errors for repositories that don't support them, while the core create/edit/delete operations work natively.

Closes #2441

…File to AgentSkillRepository interface [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH]
…eSkillRepository in SkillManageTool [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH]
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@oss-maintainer oss-maintainer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code Review Summary

Overall: The change correctly addresses #2441 by replacing WorkspaceSkillRepository with AgentSkillRepository in SkillManageTool, and adds three new default methods (readSkillFile, writeSkillFile, deleteSkillFile) to the interface for future extensibility.

CI Status: ❌ Build failed on ubuntu-latest and windows-latest

Issue: Spotless formatting violation — import order is incorrect in SkillManageTool.java.

[ERROR]     src/main/java/io/agentscope/harness/agent/tool/SkillManageTool.java
[ERROR]         @@ -18,10 +18,10 @@
[ERROR]          import·io.agentscope.core.skill.AgentSkill;
[ERROR]         +import·io.agentscope.core.skill.repository.AgentSkillRepository;
[ERROR]          import·io.agentscope.core.skill.util.SkillUtil;
[ERROR]          import·io.agentscope.core.tool.AgentTool;
[ERROR]         -import·io.agentscope.core.skill.repository.AgentSkillRepository;

Fix: Run mvn spotless:apply locally and commit the formatted result.

Code Quality:

  • ✅ Correct abstraction: Using AgentSkillRepository instead of the concrete WorkspaceSkillRepository allows for database-backed implementations
  • ✅ Default methods: The three new interface methods have sensible defaults (null/false) so existing implementations won't break
  • ✅ Javadoc: Well-documented with clear parameter descriptions and return value semantics

Action Required: Fix the import ordering and re-run CI.

@TianyuGeek001

Copy link
Copy Markdown

这样实现是否问题?看看是否应该复用AgentSkillRepository的save delete方法?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants