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 16170b7145
commit 59c98cca77
4 changed files with 129 additions and 3 deletions
+6 -2
View File
@@ -210,8 +210,12 @@ export function createSlashcommandTool(options: SlashcommandToolOptions = {}): T
return cachedDescription
}
// Pre-warm the cache immediately
buildDescription()
if (options.commands !== undefined && options.skills !== undefined) {
const allItems = [...options.commands, ...options.skills.map(skillToCommandInfo)]
cachedDescription = buildDescriptionFromItems(allItems)
} else {
buildDescription()
}
return tool({
get description() {