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:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user