Support Gemma 4 tool calling token pairs

Author: johanbrandhorstCreated Apr 6, 2026Updated Apr 8, 2026

Google's Gemma 4 has a special format for tool calling, separate from the ReAct formatting: https://ai.google.dev/gemma/docs/core/prompt-formatting-gemma4. Here's an example:

<|turn>system
<|think|>You are a helpful assistant.<|tool>declaration:get_current_temperature{...}<tool|><turn|>
<|turn>user
What's the temperature in London?<turn|>
<|turn>model
<|channel>thought
...
<channel|><|tool_call>call:get_current_temperature{location:<|"|>London<|"|>}<tool_call|><|tool_response>

It would be great to be able to create an agent using this assumed formatting for tool calling, prompt, etc.