Help me understand tool calling in the foundations models framework

Asked on 06/12/2025

1 search

Tool calling in the Foundation Models framework allows the model to execute custom functions defined in your app, enabling it to access external data or perform actions beyond text generation. This feature is particularly useful for integrating live or personal data, such as calendar events or weather information, into the model's responses, all while maintaining user privacy by running on-device.

To implement tool calling, you define a tool by conforming to the tool protocol, which includes specifying a name, a natural language description, and a call method. The model uses this information to decide when and how to call your tool. The call method can take generable input arguments, ensuring that the model provides valid inputs. Once the tool is called, its output is incorporated into the model's response.

Tool calling is designed to be flexible, allowing tools to be defined at compile time or dynamically at runtime. This capability enhances the model's functionality by allowing it to autonomously decide which tools to use based on the context of the session.

For a detailed explanation of tool calling, you can refer to the Deep dive into the Foundation Models framework (18:10) session.