Function calling dataset format: JSONL examples and a validator
For agent builders4 min read

A function calling dataset teaches a model when to call a tool, which tool, and with what arguments. Each row holds the available tools, a conversation, and the tool call the model should produce. This post shows one row in JSONL, how two common formats differ, and a short script that rejects bad rows before you train.
What a function calling dataset row contains
The Hugging Face TRL docs describe the conversational layout for tool calling. A list of messages has a user turn, an assistant turn with a tool_calls field instead of text, a tool turn with the result, and a final assistant answer. For fine-tuning, the row also needs a tools column that lists the available tools as JSON schema.
Source: TRL: dataset formats and types(opens in a new tab)
Here is one row in that style, written as a single JSONL line and broken up here for reading.
{"messages": [ {"role": "user", "content": "Turn on the living room lights."}, {"role": "assistant", "tool_calls": [ {"type": "function", "function": { "name": "control_light", "arguments": {"room": "living room", "state": "on"}}}]}, {"role": "tool", "name": "control_light", "content": "The lights in the living room are now on."}, {"role": "assistant", "content": "Done."}], "tools": [{"type": "function", "function": { "name": "control_light", "description": "Controls the lights in a room.", "parameters": {"type": "object", "properties": { "room": {"type": "string", "description": "The name of the room."}, "state": {"type": "string", "description": "The desired state: on or off."}}, "required": ["room", "state"]}}}]}In the file itself, each row sits on one line. That is what JSONL means: one JSON object per line, so a file can be streamed and appended to.
Arguments are an object here and a string there
Formats disagree on one detail that breaks pipelines. In the TRL example above, arguments is a JSON object. In OpenAI's function calling guide, the model's function_call item carries arguments as a JSON-encoded string, which you parse with json.loads before running the function. The result goes back as a function_call_output item that repeats the call_id.
Source: OpenAI: function calling(opens in a new tab)
| Detail | TRL conversational | OpenAI Responses guide |
|---|---|---|
| Call location | tool_calls in an assistant message | function_call item in the output |
| Arguments | JSON object | JSON string |
| Link to the result | Tool message with the same name | function_call_output with the same call_id |
| Tool list | tools column per row | tools parameter on each request |
Pick one canonical format for your dataset and write converters at the edges. A converter that turns strings into objects, or the reverse, is ten lines. Silent mismatches cost days.
A validator you can run today
The script below reads a JSONL file and checks four things: the line parses, every called tool exists in that row's tools list, every required argument is present, and no extra arguments appear.
import json def check_row(row): errors = [] tools = {t["function"]["name"]: t["function"] for t in row["tools"]} for msg in row["messages"]: for call in msg.get("tool_calls", []): fn = call["function"] spec = tools.get(fn["name"]) if spec is None: errors.append(f"unknown tool {fn['name']}") continue params = spec["parameters"] args = fn["arguments"] if isinstance(args, str): args = json.loads(args) for need in params.get("required", []): if need not in args: errors.append(f"{fn['name']}: missing {need}") for given in args: if given not in params["properties"]: errors.append(f"{fn['name']}: extra argument {given}") return errors def check_file(lines): for n, line in enumerate(lines, 1): try: row = json.loads(line) except json.JSONDecodeError: print(n, "invalid JSON") continue for e in check_row(row): print(n, e) row = {"tools": [{"type": "function", "function": { "name": "control_light", "parameters": {"type": "object", "properties": {"room": {}, "state": {}}, "required": ["room", "state"]}}}], "messages": [{"role": "assistant", "tool_calls": [ {"type": "function", "function": { "name": "control_light", "arguments": {"room": "kitchen"}}}]}]}check_file([json.dumps(row)])Run on the sample row it prints that the state argument is missing. A real validator would also check types and enum values from the schema, but these four checks already catch most of what goes wrong.
What human reviewers should check
A script cannot tell you whether the call was the right one. Reviewers should read each row for the points below.
- Should a tool be called at all, or should the assistant just answer?
- Is it the right tool when two look similar?
- Are argument values taken from what the user said, not invented?
- Does the final answer match the tool result?
- Does the dataset include requests the tools cannot fulfil, where the correct behavior is to say so?
That last item is often missing. If every row ends in a successful call, a model learns that a call is always the answer. Include some rows where the user asks for something outside the tool list, and some where a tool returns an error.
Tool descriptions matter as much as the rows. Anthropic's guide to building agents advises writing tool descriptions with examples, edge cases and boundaries between similar tools, and testing many example inputs to see where the model goes wrong.