Conversations and tools

Use conversations and tool calls in training, evaluation and rollout scoring. See Datasets for the dataset format and registration.

A conversation row has messages and an optional tools list. Use the roles system, user, assistant and tool. End the row with the assistant answer you want to train.

An assistant message may contain text and tool_calls together. Answer each earlier call with a tool message that names its tool_call_id. Calls in the final answer need no result. A message with calls and no text may omit content.

The following row shows a tool call and its result:

{"tools":[{"type":"function","function":{
   "name":"get_weather",
   "description":"Look up the current weather for a city",
   "parameters":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"]}}}],
 "messages":[
  {"role":"system","content":"You are a weather assistant."},
  {"role":"user","content":"What is the weather in Wellington?"},
  {"role":"assistant","content":"","tool_calls":[{"id":"call_1","type":"function",
     "function":{"name":"get_weather","arguments":{"city":"Wellington"}}}]},
  {"role":"tool","tool_call_id":"call_1","name":"get_weather","content":"18C and windy"},
  {"role":"assistant","content":"It is 18C and windy in Wellington."}
]}

A system message is optional and, when present, comes first.

Select the tokens to train

By default, SFT trains on the final assistant answer. Set loss.assistantTurns: all to include earlier answers, and loss.trainOnToolCalls: false to exclude calls in those earlier answers. See Loss settings.

If a run reports a chat-template problem, correct the named row or choose another base model.

Check tool-call answers

A smoke check tests whether a model reproduces your examples. For scoring text and tool calls, see tool-call evaluation.

Accept more than one answer

A call in the final answer states one value for each argument in arguments. To accept other values, list them in the call’s accepted, by argument name. To accept an answer that leaves an argument out, name the argument in optional.

{"role":"assistant","content":"","tool_calls":[{"id":"call_1","type":"function",
   "function":{"name":"get_weather","arguments":{"city":"Wellington","units":"metric"},
     "accepted":{"city":["Te Whanganui-a-Tara"]},
     "optional":["units"]}}]}

An answer’s call matches when:

  • each argument it gives equals the value in arguments or a value in accepted;

  • each argument it leaves out is in optional;

  • it gives no argument that is in neither arguments nor accepted.

Values compare as JSON, so 5 and 5.0 match. Text compares exactly. Evaluations, smoke checks and reinforcement runs score calls this way. Training and the chat template use arguments alone.

Use tools in reinforcement training

If a row offers tools, the model sees the tool definitions in its prompt during training, as it does when it is served. In a reinforcement run the model can call tools in its answers, but Optimize does not run them.

Tool definitions count toward the prompt’s length. If your rows have long tool lists, you may need to increase maxSeqLength. See tool-call rewards to check scoring.

Use images

Train image rows with SFT and a vision model. Remove offered tools and assistant tool calls from those rows. Reinforcement stages in a pipeline require text datasets. See Image data.

Supply an explicit mask

Set loss.explicitLossMaskColumn to a row key containing integer 0 and 1 values, one per token. The first value must be 0 and at least one later value must be 1. Each training and validation dataset needs at least one non-null mask. Rows without a mask use the other loss settings.

Choose a key other than messages, tools, prompt, completion or images. If a chat template refuses explicit masks, choose another base model. Without an explicit mask, system and user tokens never carry loss, and the final assistant answer trains in full, including its calls.