Multi-turn tool calling data preparation
Before the training can start, you need to upload all the necessary ingredients to start the training job.
For this example, we will focus on multi-turn tool calling on a file system navigation dataset, where given a conversation history of user requests and assistant tool calls, the model needs to respond with the appropriate next tool call. Unlike single-turn tool calling where each input is independent, multi-turn tool calling maintains context across the conversation. Each assistant turn produces exactly one function call. To train a model for this purpose, we will need the following:
Model compatibility
Section titled “Model compatibility”Tool calling tasks have specific model compatibility requirements:
Student models: Only GPTOSS, Qwen3 and Llama 3-family models are supported for tool-calling-closed-book and multi-turn-tool-calling-closed-book tasks.
Teacher models for multi-turn: Multi-turn tool calling (multi-turn-tool-calling-closed-book) requires one of the following teacher models:
Qwen3-235B-A22B-Instruct-2507Llama-3.1-405B-Instructopenai.gpt-oss-120b
Job description
Section titled “Job description”Describes the work you expect the model to perform; you can think of it as an LLM prompt that would help the model solve your task. In practice for a multi-turn tool calling problem, we expect two components: task_description that describes the main task and tools, a list of JSON Schemas describing the available tools and their parameters (the tool schemas should follow the OpenAI format).
The expected format is a JSON file:
{
"task_description": "You are an intelligent AI assistant that helps users navigate and manage files in a file system. Given a command or request from the user, call the appropriate file system function to complete the request.",
"tools": [
{
"type": "function",
"function": {
"name": "ls",
"description": "List the contents of the current directory.",
"parameters": {
"type": "object",
"properties": {
"a": {
"type": "boolean",
"description": "Show hidden files and directories. Defaults to False.",
"default": false
}
},
"required": []
}
}
},
{
"type": "function",
"function": {
"name": "cd",
"description": "Change the current working directory to the specified folder.",
"parameters": {
"type": "object",
"properties": {
"folder": {
"type": "string",
"description": "The folder of the directory to change to."
}
},
"required": ["folder"]
}
}
},
{
"type": "function",
"function": {
"name": "cat",
"description": "Display the contents of a file from the current directory.",
"parameters": {
"type": "object",
"properties": {
"file_name": {
"type": "string",
"description": "The name of the file to display."
}
},
"required": ["file_name"]
}
}
},
{
"type": "function",
"function": {
"name": "mkdir",
"description": "Create a new directory in the current directory.",
"parameters": {
"type": "object",
"properties": {
"dir_name": {
"type": "string",
"description": "The name of the new directory to create."
}
},
"required": ["dir_name"]
}
}
},
{
"type": "function",
"function": {
"name": "touch",
"description": "Create a new file in the current directory.",
"parameters": {
"type": "object",
"properties": {
"file_name": {
"type": "string",
"description": "The name of the new file to create."
}
},
"required": ["file_name"]
}
}
},
{
"type": "function",
"function": {
"name": "rm",
"description": "Remove a file or directory.",
"parameters": {
"type": "object",
"properties": {
"file_name": {
"type": "string",
"description": "The name of the file or directory to remove."
}
},
"required": ["file_name"]
}
}
},
{
"type": "function",
"function": {
"name": "cp",
"description": "Copy a file or directory from one location to another.",
"parameters": {
"type": "object",
"properties": {
"source": {
"type": "string",
"description": "The name of the file or directory to copy."
},
"destination": {
"type": "string",
"description": "The destination name to copy to."
}
},
"required": ["source", "destination"]
}
}
},
{
"type": "function",
"function": {
"name": "mv",
"description": "Move or rename a file or directory.",
"parameters": {
"type": "object",
"properties": {
"source": {
"type": "string",
"description": "Source name of the file or directory to move."
},
"destination": {
"type": "string",
"description": "The destination name to move to."
}
},
"required": ["source", "destination"]
}
}
}
]
}
Train/test data
Section titled “Train/test data”We need a training dataset to fine-tune the model for your specific task and a test dataset to evaluate its performance after fine-tuning. The more diverse and bigger the datasets, the better, but for the training stage we need only a few dozen examples (we’ll generate much more based on the examples you provide).
The expected format is CSV or JSONL with the following columns:
| Column | Description |
|---|---|
question | A JSON array representing the conversation history with alternating user and assistant messages |
answer | The tool call to be invoked according to the provided schema |
Conversation format
Section titled “Conversation format”The question field contains a JSON array of conversation turns. Each turn is an object with:
role: Either"user"or"assistant"content: The text content of the message (empty string for assistant turns with tool calls)tool_calls: (assistant only) An array containing exactly one tool call made by the assistant
This format allows the model to understand the full context of the conversation before generating the next tool call.
JSONL format
Section titled “JSONL format”{"question": "[{\"role\": \"user\", \"content\": \"Please list all the files in my current directory.\"}, {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"type\": \"function\", \"function\": {\"name\": \"ls\", \"arguments\": {}}}]}, {\"role\": \"user\", \"content\": \"Navigate to the backup directory.\"}, {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"type\": \"function\", \"function\": {\"name\": \"cd\", \"arguments\": {\"folder\": \"backup\"}}}]}, {\"role\": \"user\", \"content\": \"Create a new folder called archive_2024.\"}, {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"type\": \"function\", \"function\": {\"name\": \"mkdir\", \"arguments\": {\"dir_name\": \"archive_2024\"}}}]}, {\"role\": \"user\", \"content\": \"Show me what's inside config.txt.\"}]", "answer": "{\"name\": \"cat\", \"parameters\": {\"file_name\": \"config.txt\"}}"}
{"question": "[{\"role\": \"user\", \"content\": \"What's my current working directory?\"}, {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"type\": \"function\", \"function\": {\"name\": \"pwd\", \"arguments\": {}}}]}, {\"role\": \"user\", \"content\": \"Go to the downloads folder.\"}, {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"type\": \"function\", \"function\": {\"name\": \"cd\", \"arguments\": {\"folder\": \"downloads\"}}}]}, {\"role\": \"user\", \"content\": \"Find all files with \\\"invoice\\\" in their name.\"}, {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"type\": \"function\", \"function\": {\"name\": \"find\", \"arguments\": {\"path\": \".\", \"name\": \"invoice\"}}}]}, {\"role\": \"user\", \"content\": \"Copy invoice_march.pdf to the accounting folder.\"}]", "answer": "{\"name\": \"cp\", \"parameters\": {\"source\": \"invoice_march.pdf\", \"destination\": \"accounting\"}}"}
{"question": "[{\"role\": \"user\", \"content\": \"Show me all files here including hidden ones.\"}, {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"type\": \"function\", \"function\": {\"name\": \"ls\", \"arguments\": {\"a\": true}}}]}, {\"role\": \"user\", \"content\": \"Change directory to research.\"}, {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"type\": \"function\", \"function\": {\"name\": \"cd\", \"arguments\": {\"folder\": \"research\"}}}]}, {\"role\": \"user\", \"content\": \"Create a file called experiment_log.txt.\"}]", "answer": "{\"name\": \"touch\", \"parameters\": {\"file_name\": \"experiment_log.txt\"}}"}
{"question": "[{\"role\": \"user\", \"content\": \"Display the contents of my current directory.\"}, {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"type\": \"function\", \"function\": {\"name\": \"ls\", \"arguments\": {}}}]}, {\"role\": \"user\", \"content\": \"Move to the utils directory.\"}, {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"type\": \"function\", \"function\": {\"name\": \"cd\", \"arguments\": {\"folder\": \"utils\"}}}]}, {\"role\": \"user\", \"content\": \"Remove helper.js.\"}]", "answer": "{\"name\": \"rm\", \"parameters\": {\"file_name\": \"helper.js\"}}"}
{"question": "[{\"role\": \"user\", \"content\": \"List files in the current location.\"}, {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"type\": \"function\", \"function\": {\"name\": \"ls\", \"arguments\": {}}}]}, {\"role\": \"user\", \"content\": \"Navigate to the media folder.\"}, {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"type\": \"function\", \"function\": {\"name\": \"cd\", \"arguments\": {\"folder\": \"media\"}}}]}, {\"role\": \"user\", \"content\": \"Move photo_001.jpg to the gallery directory.\"}]", "answer": "{\"name\": \"mv\", \"parameters\": {\"source\": \"photo_001.jpg\", \"destination\": \"gallery\"}}"}
Understanding the conversation structure
Section titled “Understanding the conversation structure”Here’s an expanded view of what a single conversation looks like:
[
{
"role": "user",
"content": "Please list all the files in my current directory."
},
{
"role": "assistant",
"content": "",
"tool_calls": [
{
"type": "function",
"function": {
"name": "ls",
"arguments": {}
}
}
]
},
{
"role": "user",
"content": "Navigate to the backup directory."
},
{
"role": "assistant",
"content": "",
"tool_calls": [
{
"type": "function",
"function": {
"name": "cd",
"arguments": {"folder": "backup"}
}
}
]
},
{
"role": "user",
"content": "Show me what's inside config.txt."
}
]
The model receives this conversation history and should output: {"name": "cat", "parameters": {"file_name": "config.txt"}}
Key differences from single-turn tool calling
Section titled “Key differences from single-turn tool calling”| Aspect | Single-Turn Tool Calling | Multi-Turn Tool Calling |
|---|---|---|
| Input format | Plain text question | JSON array of conversation turns |
| Context | Each request is independent | Model maintains context across turns |
| Use case | One-shot function invocation | Conversational command sequences |
| Training goal | Map query → function | Understand conversation → next function |
Configuration file
Section titled “Configuration file”The configuration file specifies the task type and training parameters.
The expected format is YAML:
base:
task: multi-turn-tool-calling-closed-book
For additional configuration options, see Configuration file →