Feature request: Add a fallback renderer for runtime-named server tools in @tanstack/ai-react/ui #1329
duohelingdukele
started this conversation in
Ideas
Replies: 1 comment
|
This was an oversight, it was intended to work that way from the beginning, I'll look into this! |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem
createChatHook()/createChatUI()dispatches tool UI by an exact,module-scope
toolsComponents[toolName]mapping.This works well for statically declared client tools, but it cannot render
server tools whose names are created at runtime.
A concrete use case is multi-knowledge-base retrieval:
the server creates one read-only tool per knowledge base, such as:
kb_search_8d5...kb_search_1a2...The tool names and descriptions are intentionally runtime-derived so the model
can choose a knowledge base from its description. The client cannot know every
tool name when the module is compiled.
Currently, when a tool name is not present in
toolsComponents, the UI warnsabout the missing component and renders nothing.
partsComponents.fallbackdoes not help because tool dispatch happens before generic part fallback.
Proposal
Add an optional fallback renderer for unknown tool names:
Suggested dispatch order:
The fallback props should intentionally use broad tool-call/result types,
because the tool name and schemas are not statically known.
Why this matters
This preserves the factory's precise typing for statically registered tools,
while allowing safe rendering of server-authoritative runtime tools.
It avoids workarounds such as recreating the factory at runtime or mutating
the tool-component registry after initialization.
Acceptance criteria
to the fallback.
All reactions