previewToolSelection
previewToolSelection(
options:object):Promise<{clientToolNames:string[];serverToolNames:string[]; }>
Defined in: src/react/useChatStorage.ts:220
Preview which tools useChatStorage will include for a given prompt,
without making the actual chat request.
Runs the exact same client + server tool selection pipeline that
useChatStorage’s sendMessage runs internally — same embedding,
same autoFilterClientTools call, same server-tools branch — so the
returned names are guaranteed to match what a real request would
include for that prompt + config.
Intended for debug UIs (“show me what the model will see for this
prompt”). Pass the same clientTools, serverToolsFilter,
extraToolSets, and activeToolSets you pass to useChatStorage
so the result is faithful.
Caveats:
- For server tools, this only mirrors the dynamic
findMatchingToolspath (the one used for the responses API insendMessage). If your serverToolsFilter is a function, it’s invoked directly with the prompt embedding. - Embedding generation hits the same
/embeddingsendpoint as the real request; pass a sharedclientToolEmbeddingsCacheif you call this repeatedly to avoid re-embedding tool descriptions. - A real follow-up may also include connector tool sets carried from the previous two turns of the conversation, which this preview does not model.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
|
|
|
‐ |
|
|
|
X-API-Key auth (server-side / test harnesses). Provide this or |
|
|
|
‐ |
|
|
|
Optional cache of tool-description embeddings, shared across calls. |
|
|
‐ | |
|
|
|
‐ |
|
|
|
‐ |
|
|
() => |
Bearer-token auth (browser sessions). Provide this or |
|
|
|
‐ |
|
|
{ |
‐ |
|
|
|
‐ |
|
|
|
‐ |
|
|
|
‐ |
|
|
|
‐ |
Returns
Promise<{ clientToolNames: string[]; serverToolNames: string[]; }>