-
Notifications
You must be signed in to change notification settings - Fork 461
fix(skill): add methods for setting skill states #1055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -258,6 +258,52 @@ void testGetAllSkillIdsWithMultipleSkills() { | |
| assertTrue(skillIds.contains(skill2.getSkillId()), "Should contain second skill ID"); | ||
| assertTrue(skillIds.contains(skill3.getSkillId()), "Should contain third skill ID"); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("Should update skill active state and require explicit sync") | ||
| void testSetSkillActiveRequiresExplicitSync() { | ||
| AgentSkill skill = | ||
| new AgentSkill("test_active_skill", "Test Active Skill", "# Content", null); | ||
| AgentTool testTool = createTestTool("active_test_tool"); | ||
|
|
||
| skillBox.registration().skill(skill).agentTool(testTool).apply(); | ||
|
|
||
| String toolsGroupName = skill.getSkillId() + "_skill_tools"; | ||
|
|
||
| assertFalse( | ||
| skillBox.isSkillActive(skill.getSkillId()), | ||
| "Skill should be inactive initially"); | ||
| assertNotNull(toolkit.getToolGroup(toolsGroupName), "ToolGroup should be created"); | ||
| assertFalse( | ||
| toolkit.getToolGroup(toolsGroupName).isActive(), | ||
| "ToolGroup should be inactive initially"); | ||
|
|
||
| skillBox.setSkillActive(skill.getSkillId(), true); | ||
| skillBox.syncToolGroupStates(); | ||
| assertTrue( | ||
|
Comment on lines
+262
to
+283
|
||
| skillBox.isSkillActive(skill.getSkillId()), | ||
| "Skill logical state should be active now"); | ||
| assertTrue( | ||
| toolkit.getToolGroup(toolsGroupName).isActive(), | ||
| "ToolGroup should be active after sync"); | ||
|
|
||
| skillBox.setSkillActive(skill.getSkillId(), false); | ||
|
|
||
| // The physical state (Toolkit) has not changed yet (the framework will not | ||
| // automatically synchronize for you) | ||
| assertFalse( | ||
| skillBox.isSkillActive(skill.getSkillId()), | ||
| "Skill logical state should be inactive"); | ||
| assertTrue( | ||
| toolkit.getToolGroup(toolsGroupName).isActive(), | ||
| "ToolGroup should STILL be active before explicit sync"); | ||
|
|
||
| skillBox.syncToolGroupStates(); | ||
|
|
||
| assertFalse( | ||
| toolkit.getToolGroup(toolsGroupName).isActive(), | ||
| "ToolGroup should be inactive after sync"); | ||
| } | ||
| } | ||
|
|
||
| @Nested | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setSkillActivesilently no-ops whenskillIdis unknown (becauseSkillRegistry#setSkillActiveignores missing registrations) but still logs as if the state was updated. This can hide configuration mistakes and makes it hard for callers to know whether deactivation actually happened. Consider validatingexists(skillId)and throwing anIllegalArgumentException(or returning a boolean / logging a warning when the skill is not found).