🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
♻️ refactor(prompts): place task-conditional framing before <available_skills> (#23516)
AmAzing-5d4975b80513
diff --git a/packages/context-engine/src/providers/__tests__/__snapshots__/SkillContextProvider.test.ts.snap b/packages/context-engine/src/providers/__tests__/__snapshots__/SkillContextProvider.test.ts.snapindex 42c601f01dd..c37da3479ed 100644--- a/packages/context-engine/src/providers/__tests__/__snapshots__/SkillContextProvider.test.ts.snap+++ b/packages/context-engine/src/providers/__tests__/__snapshots__/SkillContextProvider.test.ts.snap@@ -5,56 +5,62 @@ exports[`SkillContextProvider > should directly inject content for activated skiUse \`lh task\` to manage tasks.</task_guides>+The following skills provide specialized instructions for specific tasks.+Use the activateSkill tool to load a skill when the user's task matches its description.+<available_skills><skill name="Artifacts">Generate interactive UI components</skill>-</available_skills>--Use the activateSkill tool to activate a skill when needed."+</available_skills>"`;exports[`SkillContextProvider > should handle all skills activated (no available_skills list) 1`] = `"Task skill content here"`;exports[`SkillContextProvider > should inject skill metadata when skills are provided 1`] = `-"<available_skills>+"The following skills provide specialized instructions for specific tasks.+Use the activateSkill tool to load a skill when the user's task matches its description.++<available_skills><skill name="Artifacts" location="/path/to/skills/artifacts/SKILL.md">Generate interactive UI components</skill><skill name="My Skill">Custom skill description</skill>-</available_skills>--Use the activateSkill tool to activate a skill when needed."+</available_skills>"`;exports[`SkillContextProvider > should merge with existing system message 1`] = `"You are a helpful assistant.+The following skills provide specialized instructions for specific tasks.+Use the activateSkill tool to load a skill when the user's task matches its description.+<available_skills><skill name="Artifacts" location="/path/to/skills/artifacts/SKILL.md">Generate interactive UI components</skill><skill name="My Skill">Custom skill description</skill>-</available_skills>--Use the activateSkill tool to activate a skill when needed."+</available_skills>"`;exports[`SkillContextProvider > should only inject lightweight metadata without content field 1`] = `-"<available_skills>- <skill name="Artifacts" location="/path/to/skills/artifacts/SKILL.md">Generate interactive UI components</skill>-</available_skills>+"The following skills provide specialized instructions for specific tasks.+Use the activateSkill tool to load a skill when the user's task matches its description.-Use the activateSkill tool to activate a skill when needed."+<available_skills>+ <skill name="Artifacts" location="/path/to/skills/artifacts/SKILL.md">Generate interactive UI components</skill>+</available_skills>"`;exports[`SkillContextProvider > should render XML with location attribute 1`] = `-"<available_skills>+"The following skills provide specialized instructions for specific tasks.+Use the activateSkill tool to load a skill when the user's task matches its description.++<available_skills><skill name="PDF Processing" location="/path/to/skills/pdf-processing/SKILL.md">Extracts text from PDF files</skill><skill name="Data Analysis" location="/path/to/skills/data-analysis/SKILL.md">Analyzes datasets and generates charts</skill>-</available_skills>--Use the activateSkill tool to activate a skill when needed."+</available_skills>"`;exports[`SkillContextProvider > should render XML without location when not provided 1`] = `-"<available_skills>- <skill name="My Skill">Custom skill description</skill>-</available_skills>+"The following skills provide specialized instructions for specific tasks.+Use the activateSkill tool to load a skill when the user's task matches its description.-Use the activateSkill tool to activate a skill when needed."+<available_skills>+ <skill name="My Skill">Custom skill description</skill>+</available_skills>"`;diff --git a/packages/prompts/src/prompts/skills/index.test.ts b/packages/prompts/src/prompts/skills/index.test.tsindex b45763c5ea3..6e59eb9b226 100644--- a/packages/prompts/src/prompts/skills/index.test.ts+++ b/packages/prompts/src/prompts/skills/index.test.ts@@ -44,12 +44,13 @@ describe('skillsPrompts', () => {},];- const expected = `<available_skills>+ const expected = `The following skills provide specialized instructions for specific tasks.+Use the activateSkill tool to load a skill when the user's task matches its description.++<available_skills><skill name="PDF Processing" location="/path/to/skills/pdf-processing/SKILL.md">Extracts text and tables from PDF files</skill><skill name="Data Analysis" location="/path/to/skills/data-analysis/SKILL.md">Analyzes datasets and generates charts</skill>-</available_skills>--Use the activateSkill tool to activate a skill when needed.`;+</available_skills>`;expect(skillsPrompts(skills)).toBe(expected);});@@ -69,16 +70,39 @@ Use the activateSkill tool to activate a skill when needed.`;},];- const expected = `<available_skills>+ const expected = `The following skills provide specialized instructions for specific tasks.+Use the activateSkill tool to load a skill when the user's task matches its description.++<available_skills><skill name="Artifacts" location="/path/to/skills/artifacts/SKILL.md">Generate interactive UI components</skill><skill name="My Skill">Custom skill description</skill>-</available_skills>--Use the activateSkill tool to activate a skill when needed.`;+</available_skills>`;expect(skillsPrompts(skills)).toBe(expected);});+ it('should include filesystem skill loading and relative-path resolution instructions for project/device skills', () => {+ const skills: SkillItem[] = [+ {+ description: 'Device writing guidance',+ identifier: 'device:writing',+ location: '/Users/dev/.agents/skills/writing/SKILL.md',+ name: 'writing',+ source: 'device',+ },+ ];++ expect(skillsPrompts(skills)).toBe(+ `The following skills provide specialized instructions for specific tasks.+Use the activateSkill tool to load a skill when the user's task matches its description.+For a skill with source="project" or source="device", load it by calling the readFile tool on its \`location\` path and resolve relative paths against its parent directory (parent of SKILL.md).++<available_skills>+ <skill name="writing" source="device" location="/Users/dev/.agents/skills/writing/SKILL.md">Device writing guidance</skill>+</available_skills>`,+ );+ });+it('should return empty string for empty skills array', () => {expect(skillsPrompts([])).toBe('');});diff --git a/packages/prompts/src/prompts/skills/index.ts b/packages/prompts/src/prompts/skills/index.tsindex 7f509ef47c0..248d413c83a 100644--- a/packages/prompts/src/prompts/skills/index.ts+++ b/packages/prompts/src/prompts/skills/index.ts@@ -31,12 +31,13 @@ export const skillsPrompts = (skills: SkillItem[]) => {(skill) => skill.source === 'project' || skill.source === 'device',);const filesystemHint = hasFilesystemSkill- ? `\nFor a skill with source="project" or source="device", load it by calling the readFile tool on its \`location\` path before following its instructions.`+ ? `\nFor a skill with source="project" or source="device", load it by calling the readFile tool on its \`location\` path and resolve relative paths against its parent directory (parent of SKILL.md).`: '';- return `<available_skills>-${skillTags}-</available_skills>+ return `The following skills provide specialized instructions for specific tasks.+Use the activateSkill tool to load a skill when the user's task matches its description.${filesystemHint}-Use the activateSkill tool to activate a skill when needed.${filesystemHint}`;+<available_skills>+${skillTags}+</available_skills>`;};diff --git a/src/services/chat/chat.test.ts b/src/services/chat/chat.test.tsindex 208a5b8739f..44225797bfc 100644--- a/src/services/chat/chat.test.ts+++ b/src/services/chat/chat.test.ts@@ -1260,7 +1260,7 @@ describe('ChatService', () => {);expect(requestMessages[0].content).not.toContain('<available_skills>');expect(requestMessages[0].content).not.toContain(- 'Use the activateSkill tool to activate a skill when needed.',+ "Use the activateSkill tool to load a skill when the user's task matches its description.",);expect(requestMessages[0].content).toContain('<tool name="SEO">');expect(requestMessages[1]).toEqual(