Overview
The tool use workflow follows four steps:- Define tools as JSON in the system prompt or via
.apply_chat_template() - Generate a response where the model outputs function calls between special tokens
- Execute the function and return results as a
toolrole message - Regenerate to let the model interpret results and respond to the user
<|tool_call_start|> and <|tool_call_end|> tokens. LFM2 additionally wraps tool definitions in <|tool_list_start|>/<|tool_list_end|> and responses in <|tool_response_start|>/<|tool_response_end|>.
By default, models generate Pythonic function calls. Add “Output function calls as JSON” to your system prompt for JSON format.
Defining Tools
You have two options for providing tool definitions. Option 1: JSON in the system prompt (recommended).apply_chat_template()