expandToolSetsAdditive
expandToolSetsAdditive(
matchedNames:Set<string>,availableNames:Set<string>,scores:Map<string,number>,toolSets:ToolSet[],activeSetNames?:ReadonlySet<string>):Set<string>
Defined in: src/lib/tools/serverTools.ts:976
Additively expand tool sets: when any anchor of a set scores at or above
its anchorMinSimilarity, all set members are added to the result.
Original matches are preserved; multiple sets can expand independently.
Members of sets that don’t activate are kept if they were individually
matched. We deliberately don’t strip orphans: the cost of a single
borderline tool slipping into the request is cheap (a few extra bytes,
no behavioral impact) but stripping legitimate matches like
create_file 0.55 on prompts where patch_file doesn’t also clear the
anchor threshold would silently break app-creation flows. Recall over
precision.
Use this for server-side toolkit suites where the LLM needs the full
call chain (e.g. fal_list_models → fal_model_schema → fal_queue_submit →
fal_queue_status → fal_queue_result). Differs from applyToolSets, which
replaces non-set matches when a set activates.
To express “any member triggers the set” (not specific anchors), pass
anchors: members when defining the ToolSet.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
|
|
Names selected by semantic matching |
|
|
|
All tool names available for selection |
|
|
|
Map of tool name → similarity score |
|
|
|
Tool sets to evaluate |
|
|
|
Set names that should expand unconditionally, bypassing the anchor-similarity check. Use this when conversation state implies a set should be present regardless of how the current prompt is phrased (e.g., a slide deck artifact already exists in the conversation). |
Returns
Set<string>
Set including original matches plus members of any activated set