fix: generate skill/slashcommand descriptions synchronously when pre-provided (#1087)

* fix: generate skill/slashcommand tool descriptions synchronously when pre-provided

When skills are passed via options (pre-resolved), build the tool description
synchronously instead of fire-and-forget async. This eliminates the race
condition where the description getter returns the bare prefix before the
async cache-warming microtask completes.

Fixes #1039

* chore: changes by sisyphus-dev-ai

---------

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
This commit is contained in:
Sisyphus
2026-01-25 14:52:50 +09:00
committed by GitHub
parent 0aa8f486af
commit 208af055ef
4 changed files with 129 additions and 3 deletions
+8 -1
View File
@@ -147,7 +147,14 @@ export function createSkillTool(options: SkillLoadOptions = {}): ToolDefinition
return cachedDescription
}
getDescription()
if (options.skills) {
const skillInfos = options.skills.map(loadedSkillToInfo)
cachedDescription = skillInfos.length === 0
? TOOL_DESCRIPTION_NO_SKILLS
: TOOL_DESCRIPTION_PREFIX + formatSkillsXml(skillInfos)
} else {
getDescription()
}
return tool({
get description() {