Skip to content

fix(skill-runtime): use skill name instead of composite ID for SkillFilter matching …issues/1768#1771

Merged
chickenlj merged 1 commit into
agentscope-ai:mainfrom
xseruer:fix_SkillFilter
Jun 16, 2026
Merged

fix(skill-runtime): use skill name instead of composite ID for SkillFilter matching …issues/1768#1771
chickenlj merged 1 commit into
agentscope-ai:mainfrom
xseruer:fix_SkillFilter

Conversation

@xseruer

@xseruer xseruer commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

…issues/1768

AgentScope-Java Version

2.0.0-SNAPSHOT

Description

Background

SkillFilter.only("host-forensics-client") does not work as expected when used with HarnessAgent. The whitelisted skill is silently filtered out, and the rendered skill prompt is empty.

Root Cause

In SkillPromptBuilder#render(SkillCatalog, SkillFilter), the code passes entry.skill().getSkillId() to SkillFilter#isAllowed(). However, getSkillId() returns a composite ID in the format name_source (e.g. host-forensics-client_filesystem-agentscope_skills), while users naturally pass bare skill names (e.g. host-forensics-client) to SkillFilter.only(...). Since isAllowed() performs an exact contains() check, the match always fails, making WHITELIST / BLACKLIST / OVERLAY_ENABLE / OVERLAY_DISABLE modes effectively unusable.

Fix

Replace entry.skill().getSkillId() with entry.skill().getName() in SkillPromptBuilder#render() so the filter key matches the bare skill name that users configure.

Changed files:

  • SkillPromptBuilder.java — 1-line fix: getSkillId()getName()
  • SkillRuntimeTest.java — updated existing test to use bare name; added new test filterWithBareNameMatchesCompositeId that reproduces the reported scenario

@xseruer xseruer requested a review from a team June 16, 2026 02:00
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@AgentScopeJavaBot AgentScopeJavaBot added bug Something isn't working area/harness agentscope-harness (test/runtime support) labels Jun 16, 2026

@AgentScopeJavaBot AgentScopeJavaBot 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.

🤖 AI Review

This is a clean, focused bug fix that corrects the SkillFilter matching logic in SkillPromptBuilder.render(). The root cause is accurately identified: getSkillId() returns a composite name_source string, while SkillFilter was designed to accept bare skill names (as confirmed by its field name skillNames, the Javadoc example SkillFilter.only("skill_a", "skill_b"), and the HarnessAgent.Builder.enableSkills(String... skillNames) API). The 1-line fix (getSkillId()getName()) is correct, minimal, and consistent with the intended contract. The variable rename from id to skillName improves readability. Test coverage is solid — the existing test is updated to match the correct behavior, and the new test filterWithBareNameMatchesCompositeId directly reproduces the reported scenario with realistic data. The rendered <skill-id> in the prompt still uses the composite ID (for load_skill_through_path), so there's no downstream breakage. All filter modes (WHITELIST, BLACKLIST, OVERLAY_ENABLE, OVERLAY_DISABLE) benefit from this single-point fix.

@AgentScopeJavaBot AgentScopeJavaBot 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.

🤖 AI Review

This is a clean, focused bug fix that corrects the SkillFilter matching logic in SkillPromptBuilder.render(). The root cause is accurately identified: getSkillId() returns a composite name_source string, while SkillFilter was designed to accept bare skill names (as confirmed by its field name skillNames, the Javadoc example SkillFilter.only("skill_a", "skill_b"), and the HarnessAgent.Builder.enableSkills(String... skillNames) API). The 1-line fix (getSkillId()getName()) is correct, minimal, and consistent with the intended contract. The variable rename from id to skillName improves readability. Test coverage is solid — the existing test is updated to match the correct behavior, and the new test filterWithBareNameMatchesCompositeId directly reproduces the reported scenario with realistic data. The rendered <skill-id> in the prompt still uses the composite ID (for load_skill_through_path), so there's no downstream breakage. All filter modes (WHITELIST, BLACKLIST, OVERLAY_ENABLE, OVERLAY_DISABLE) benefit from this single-point fix.

@chickenlj chickenlj 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.

LGTM.

@chickenlj chickenlj merged commit bece9f0 into agentscope-ai:main Jun 16, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/harness agentscope-harness (test/runtime support) bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants