fix(skill): eagerly build description for preloaded skills
This commit is contained in:
@@ -101,7 +101,7 @@ describe("skill tool - synchronous description", () => {
|
||||
const tool = createSkillTool({ skills: [] })
|
||||
|
||||
// then
|
||||
expect(tool.description).toContain("No skills are currently available")
|
||||
expect(tool.description).toContain("No skills or commands are currently available")
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -171,10 +171,13 @@ export function createSkillTool(options: SkillLoadOptions = {}): ToolDefinition
|
||||
return cachedDescription
|
||||
}
|
||||
|
||||
// Eagerly build description if possible
|
||||
if (options.skills && options.commands !== undefined) {
|
||||
// Eagerly build description when callers pre-provide skills/commands.
|
||||
if (options.skills !== undefined) {
|
||||
const skillInfos = options.skills.map(loadedSkillToInfo)
|
||||
cachedDescription = formatCombinedDescription(skillInfos, options.commands)
|
||||
const commandsForDescription = options.commands ?? []
|
||||
cachedDescription = formatCombinedDescription(skillInfos, commandsForDescription)
|
||||
} else if (options.commands !== undefined) {
|
||||
cachedDescription = formatCombinedDescription([], options.commands)
|
||||
} else {
|
||||
void buildDescription()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user