Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(skill): validate resource path before activating skill#1308

Merged
LearningGp merged 3 commits into
agentscope-ai:mainfrom
JGoP-L:fix-skill-load-path-description
Apr 29, 2026
Merged

fix(skill): validate resource path before activating skill#1308
LearningGp merged 3 commits into
agentscope-ai:mainfrom
JGoP-L:fix-skill-load-path-description

Conversation

@JGoP-L
Copy link
Copy Markdown
Contributor

@JGoP-L JGoP-L commented Apr 27, 2026

AgentScope-Java Version

1.0.12-SNAPSHOT

Description

Closes #1289.

This PR fixes the load_skill_through_path behavior when the model passes an invalid resource path such as ..

Background:

  • The tool description and path parameter schema were incomplete/malformed, which could mislead models about how to load skill content.
  • Calling load_skill_through_path with an invalid path returned an error, but still activated the skill before validating the resource path.

Changes made:

  • Clarified the tool description to explicitly instruct models to use path="SKILL.md" for skill documentation.
  • Clarified the path parameter description and explicitly disallowed ., ./, directories, and absolute paths.
  • Changed activation order so a skill is activated only after SKILL.md or a valid resource path is successfully loaded.
  • Added regression tests for tool/schema guidance and invalid-path activation behavior.

How to test:

  • Run mvn -pl agentscope-core -Dtest='io.agentscope.core.skill.*Test' test

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn -pl agentscope-core -Dtest='io.agentscope.core.skill.*Test' test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

@JGoP-L JGoP-L requested review from a team and Copilot April 27, 2026 07:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 addresses a bug in the load_skill_through_path built-in tool where invalid resource paths (e.g., ".") could lead to a skill being activated before the path/resource was validated, and improves schema/tool guidance to reduce model misuse.

Changes:

  • Updated load_skill_through_path tool description and JSON schema parameter description to explicitly guide using path="SKILL.md" and discourage invalid paths like ".".
  • Reordered skill activation so the skill is activated only after SKILL.md or a valid resource has been successfully resolved.
  • Added regression tests to verify the updated tool/schema guidance and that invalid paths do not activate the skill.

Reviewed changes

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

File Description
agentscope-core/src/main/java/io/agentscope/core/skill/SkillToolFactory.java Updates tool description/schema text and moves skill activation to occur only after successful resource load.
agentscope-core/src/test/java/io/agentscope/core/skill/SkillBoxToolsTest.java Adds assertions for improved tool/schema guidance and a regression test ensuring invalid path="." does not activate the skill.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@LearningGp
Copy link
Copy Markdown
Collaborator

PTAL @fang-tech

Copy link
Copy Markdown
Collaborator

@fang-tech fang-tech left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Collaborator

@LearningGp LearningGp left a comment

Choose a reason for hiding this comment

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

LGTM

@LearningGp LearningGp merged commit 887728a into agentscope-ai:main Apr 29, 2026
5 checks passed
liangxingguang pushed a commit to liangxingguang/agentscope-java that referenced this pull request May 21, 2026
…e-ai#1308)

## AgentScope-Java Version

1.0.12-SNAPSHOT

## Description

Closes agentscope-ai#1289.

This PR fixes the `load_skill_through_path` behavior when the model
passes an invalid resource path such as `.`.

Background:
- The tool description and `path` parameter schema were
incomplete/malformed, which could mislead models about how to load skill
content.
- Calling `load_skill_through_path` with an invalid path returned an
error, but still activated the skill before validating the resource
path.

Changes made:
- Clarified the tool description to explicitly instruct models to use
`path="SKILL.md"` for skill documentation.
- Clarified the `path` parameter description and explicitly disallowed
`.`, `./`, directories, and absolute paths.
- Changed activation order so a skill is activated only after `SKILL.md`
or a valid resource path is successfully loaded.
- Added regression tests for tool/schema guidance and invalid-path
activation behavior.

How to test:
- Run `mvn -pl agentscope-core -Dtest='io.agentscope.core.skill.*Test'
test`

## Checklist

Please check the following items before code is ready to be reviewed.

- [ ] Code has been formatted with `mvn spotless:apply`
- [x] All tests are passing (`mvn -pl agentscope-core
-Dtest='io.agentscope.core.skill.*Test' test`)
- [x] Javadoc comments are complete and follow project conventions
- [ ] Related documentation has been updated (e.g. links, examples,
etc.)
- [x] Code is ready for review
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.

[Bug]:load_skill_through_path tool description broken, causes model to pass invalid path='.'

4 participants