-
Notifications
You must be signed in to change notification settings - Fork 14.1k
webui: Client-side implementation of tool calling (with two tools) #18059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Hey, thanks a lot for your contribution! Will take a closer look at this when also reviewing and testing #17487. These are in a way intertwining changes and we need to be thoughtful when merging changes to the master branch. |
|
This approach is interesting, but for a cleaner and more extensible codebase, it would be better to implement proper MCP protocol support first. This means providing small example MCP servers in Python (calculator, web browsing, etc.), and then nothing would prevent us from adding local JavaScript execution as an additional MCP tool, using the same unified context management architecture. |
|
MCP is a much higher bar to clear, and I don’t see it as a replacement for this. Client-side tools immediately benefit everyone, where MCP is a much more advanced, much more niche technology. It certainly gets lots of hype because it can do cool things, but having tools that exist purely in the chat app allows everyone to instantly to give their models access to a code interpreter and calculator with no additional configuration, no additional services, etc. One could even see MCP as a subset of this client side tool registry: there could be an MCP tool which lets models interact with configured MCP servers to discover which tools they offer and then run those tools through the MCP tool plugin. Presenting tools over MCP that are just built into the client feels like only having a hammer and seeing every problem as a nail. Tool calls are the first level abstraction here, and MCPs are an abstraction on top of that. There’s no need to use MCP to access the tool calls that are part of the application itself; MCP is meant for connecting with external systems. |
…l and (javascript) code interpreter tool
…reter documentation around async
This PR allows webui to give models access to two tools: a calculator and a code interpreter. The calculator is a simple expression calculator, used to enhance math abilities. The code interpreter runs arbitrary JavaScript in a (relatively isolated) Web Worker, and returns the output to the model, which can be used for more advanced analysis.
This PR also lays the groundwork for a modular tool system, such that one could easily imagine adding a Canvas tool or a Web Search tool.
When an assistant message emits tool calls, the web UI...
Included tools
output + the final evaluated value, with improved error reporting (line/column/snippet).
UX changes
(arguments + result + timing) to avoid extra message bubbles.
Configuration & extensibility
a Tools section (toggles + per-tool fields like timeout), and defaults are derived from tool registrations.
Tests
reactivity/regressions, etc. These tests were created when bugs were encountered. I would be perfectly fine with throwing most of them away, but I figured there was no harm in including them.
Videos
Calculator tool
Screen.Recording.2025-12-15.at.8.10.04.AM.mov
Code Interpreter tool
Screen.Recording.2025-12-15.at.8.11.08.AM.mov
Code interpreter and calculator, including the model recovering from a syntax error in its first code interpreter attempt
Screen.Recording.2025-12-15.at.8.14.48.AM.mov
Demonstrating how tool calling works for an Instruct model
Screen.Recording.2025-12-15.at.8.12.32.AM.mov
Demonstrating how the regenerate button will correctly treat the entire response as one message, instead of regenerating just the last segment after the last tool call.
Screen.Recording.2025-12-15.at.8.39.48.AM.mov
Deleting an entire response
Screen.Recording.2025-12-15.at.8.53.48.AM.mov
Screenshots
New Settings Screen for Tools
Known Bugs